@gitkraken/core-gitlens 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/dist/git/context.d.ts +1 -0
- package/dist/git/context.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +1 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/models/graph.d.ts +2 -1
- package/dist/git/models/graph.js.map +1 -1
- package/dist/git/models/graphSession.d.ts +8 -0
- package/dist/git/models/graphSession.js.map +1 -1
- package/dist/git/parsers/diffParser.js +1 -1
- package/dist/git/utils/hiddenRefs.utils.d.ts +26 -0
- package/dist/git/utils/hiddenRefs.utils.js +89 -0
- package/dist/git/utils/hiddenRefs.utils.js.map +1 -0
- package/dist/git/utils/search.utils.d.ts +3 -1
- package/dist/git/utils/search.utils.js +3 -1
- package/dist/git/utils/search.utils.js.map +1 -1
- package/dist/git-cli/exec/git.js +2 -1
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/locator.d.ts +2 -1
- package/dist/git-cli/exec/locator.js +11 -3
- package/dist/git-cli/exec/locator.js.map +1 -1
- package/dist/git-cli/parsers/blameParser.js +1 -1
- package/dist/git-cli/parsers/indexParser.js +1 -1
- package/dist/git-cli/parsers/statusParser.js +1 -1
- package/dist/git-cli/providers/branches.js +1 -1
- package/dist/git-cli/providers/commits.js +3 -2
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/graph.d.ts +11 -1
- package/dist/git-cli/providers/graph.js +156 -38
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.js +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/git-cli/providers/tags.js +1 -1
- package/dist/git-cli/service.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/integrations/integrationService.js +35 -8
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/models/azurePullRequestWrites.d.ts +3 -1
- package/dist/plus/integrations/models/integration.d.ts +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueTrackerWrites.d.ts +12 -3
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/azure/models.d.ts +1 -1
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/azurePullRequestWriteErrors.d.ts +6 -2
- package/dist/plus/integrations/providers/azurePullRequestWriteErrors.js +44 -10
- package/dist/plus/integrations/providers/azurePullRequestWriteErrors.js.map +1 -1
- package/dist/plus/integrations/providers/azurePullRequestWrites.d.ts +1 -0
- package/dist/plus/integrations/providers/azurePullRequestWrites.js +28 -13
- package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/providers/github.js +1 -1
- package/dist/plus/integrations/providers/jira-server.d.ts +10 -0
- package/dist/plus/integrations/providers/jira-server.js +16 -1
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueWrites.d.ts +6 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js +60 -11
- package/dist/plus/integrations/providers/jiraIssueWrites.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +6 -2
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +3 -0
- package/dist/plus/integrations/providers/providersApi.js +13 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/currentAccount.d.ts +1 -1
- package/dist/plus/integrations/reads/currentAccount.js +1 -1
- package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +4 -1
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +40 -5
- package/docs/kepler-read-api-parity.md +2 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azurePullRequestWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azurePullRequestWrites.ts"],"sourcesContent":["import type {\n\tAzurePullRequestCreateCapabilityOptions,\n\tAzurePullRequestCreateCapabilityResult,\n\tAzurePullRequestMergeStrategy,\n\tAzurePullRequestRepository,\n\tAzurePullRequestWriteFailure,\n\tAzurePullRequestWriteOptions,\n\tAzurePullRequestWriteResult,\n\tAzurePullRequestWriteTargetResult,\n\tAzureServerPullRequestWriteOptions,\n\tAzureServerPullRequestWriteScope,\n\tAzureWrittenPullRequest,\n} from '../models/azurePullRequestWrites.js';\nimport type { AzurePullRequest, AzureRepository } from './azure/models.js';\nimport { encodeAzurePathSegment, getAzurePullRequestWebUrl } from './azure/models.js';\nimport {\n\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tverifyAzureServerCollection,\n} from './azure/writeIdentity.js';\nimport { AzurePullRequestWriteError, toAzurePullRequestWriteFailure } from './azurePullRequestWriteErrors.js';\nimport { isWorkItemWriteScope } from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.js';\nimport { isCommitSha, isPositiveInt32, isWriteIdentifier, sameIdentifier } from './utils/writeInputs.js';\n\nconst azureBaseUrl = 'https://dev.azure.com';\nconst branchRefPrefix = 'refs/heads/';\nconst mergeStrategyPolicyId = 'fa4e907d-c16b-4a4c-9dfa-4916e5d171ab';\nconst strategySettings = {\n\tnoFastForward: 'allowNoFastForward',\n\tsquash: 'allowSquash',\n\trebase: 'allowRebase',\n\trebaseMerge: 'allowRebaseMerge',\n} as const;\nconst mergeStrategies: AzurePullRequestMergeStrategy[] = ['noFastForward', 'squash', 'rebase', 'rebaseMerge'];\n\ntype MergePolicy = {\n\tisEnabled?: boolean;\n\tisDeleted?: boolean;\n\tisBlocking?: boolean;\n\tsettings?: Partial<Record<(typeof strategySettings)[AzurePullRequestMergeStrategy] | 'useSquashMerge', boolean>>;\n};\n\ntype CompletionCapability = Extract<AzurePullRequestWriteTargetResult, { ok: true }>['capabilities']['complete'];\ntype WriteOptions = AzurePullRequestWriteOptions | AzureServerPullRequestWriteOptions;\ntype CompletionOptions = Extract<WriteOptions, { action: 'complete' }>;\ntype FailureReason = AzurePullRequestWriteFailure['reason'];\ntype PullRequestSnapshot = Omit<AzureWrittenPullRequest, 'state'> & {\n\tstate: AzureWrittenPullRequest['state'] | undefined;\n};\ntype WriteStatus = Extract<AzurePullRequestWriteResult, { ok: true }>['status'];\n\nfunction isPathSegment(value: unknown): value is string {\n\treturn isWriteIdentifier(value) && value !== '.' && value !== '..' && !value.includes('/') && !value.includes('\\\\');\n}\n\nfunction isBranchRef(ref: unknown): ref is string {\n\treturn (\n\t\ttypeof ref === 'string' &&\n\t\tref.startsWith(branchRefPrefix) &&\n\t\tref.length > branchRefPrefix.length &&\n\t\t![...ref].some(character => character <= ' ' || '~^:?*[\\\\\\x7f'.includes(character)) &&\n\t\t!ref.includes('..') &&\n\t\t!ref.includes('@{') &&\n\t\t!ref.endsWith('.') &&\n\t\tref.split('/').every(part => part.length > 0 && !part.startsWith('.') && !part.endsWith('.lock'))\n\t);\n}\n\nexport function isAzurePullRequestScope(\n\toptions: AzurePullRequestCreateCapabilityOptions | AzureServerPullRequestWriteScope,\n): boolean {\n\tif (options.providerId === 'azure-devops-server') {\n\t\treturn isWorkItemWriteScope(options) && isPathSegment(options.repository);\n\t}\n\n\treturn (\n\t\t(options.providerId === undefined || options.providerId === 'azureDevOps') &&\n\t\tisWriteIdentifier(options.connectionId) &&\n\t\ttypeof options.organization === 'string' &&\n\t\t/^[a-z0-9][a-z0-9-]*$/i.test(options.organization) &&\n\t\tisPathSegment(options.project) &&\n\t\tisPathSegment(options.repository) &&\n\t\t(options.expectedAccountId === undefined || isWriteIdentifier(options.expectedAccountId))\n\t);\n}\n\nfunction isTitle(title: unknown): title is string {\n\treturn typeof title === 'string' && title.trim().length > 0;\n}\n\nfunction isDescription(description: unknown): boolean {\n\treturn description === undefined || (typeof description === 'string' && description.length <= 4000);\n}\n\nexport function isAzurePullRequestWrite(options: WriteOptions): boolean {\n\tif (\n\t\t(options.providerId !== undefined &&\n\t\t\toptions.providerId !== 'azureDevOps' &&\n\t\t\toptions.providerId !== 'azure-devops-server') ||\n\t\t!isAzureGuid(options.projectId) ||\n\t\t!isAzureGuid(options.repositoryId) ||\n\t\t!isWriteIdentifier(options.expectedAccountId)\n\t) {\n\t\treturn false;\n\t}\n\n\tif (options.action === 'create') {\n\t\treturn (\n\t\t\tisBranchRef(options.sourceRef) &&\n\t\t\tisBranchRef(options.targetRef) &&\n\t\t\toptions.sourceRef !== options.targetRef &&\n\t\t\tisTitle(options.title) &&\n\t\t\tisDescription(options.description)\n\t\t);\n\t}\n\n\tif (!isPositiveInt32(options.number)) return false;\n\n\tswitch (options.action) {\n\t\tcase 'edit':\n\t\t\treturn (\n\t\t\t\t(options.title !== undefined || options.description !== undefined) &&\n\t\t\t\t(options.title === undefined || isTitle(options.title)) &&\n\t\t\t\tisDescription(options.description)\n\t\t\t);\n\t\tcase 'abandon':\n\t\tcase 'reactivate':\n\t\t\treturn true;\n\t\tcase 'complete':\n\t\t\treturn (\n\t\t\t\tmergeStrategies.includes(options.strategy) &&\n\t\t\t\tisBranchRef(options.expectedSourceRef) &&\n\t\t\t\tisBranchRef(options.expectedTargetRef) &&\n\t\t\t\toptions.expectedSourceRef !== options.expectedTargetRef &&\n\t\t\t\tisCommitSha(options.expectedSourceSha) &&\n\t\t\t\tisCommitSha(options.expectedTargetSha)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction allowsStrategy(policy: MergePolicy, strategy: AzurePullRequestMergeStrategy): boolean {\n\tconst settings = policy.settings;\n\tif (settings == null) return false;\n\tif (mergeStrategies.some(type => settings[strategySettings[type]] != null)) {\n\t\treturn settings[strategySettings[strategy]] === true;\n\t}\n\n\treturn (\n\t\t(strategy === 'squash' && settings.useSquashMerge === true) ||\n\t\t(strategy === 'noFastForward' && settings.useSquashMerge === false)\n\t);\n}\n\nfunction getCompletionRefFailure(\n\toptions: CompletionOptions,\n\tpullRequest: AzureWrittenPullRequest,\n): FailureReason | undefined {\n\tif (\n\t\tpullRequest.sourceRef !== options.expectedSourceRef ||\n\t\t!sameIdentifier(pullRequest.sourceSha, options.expectedSourceSha)\n\t) {\n\t\treturn 'source-changed';\n\t}\n\tif (pullRequest.targetRef !== options.expectedTargetRef) return 'target-changed';\n\n\treturn undefined;\n}\n\nfunction getCompletionStateFailure(raw: AzurePullRequest): FailureReason | undefined {\n\tif (raw.forkSource != null) return 'unsupported';\n\tif (raw.isDraft) return 'policy-blocked';\n\tif (raw.status !== 'active' || raw.mergeStatus === 'queued') return 'conflict';\n\n\treturn undefined;\n}\n\nfunction getMergePreviewFailure(raw: AzurePullRequest, targetSha: string): FailureReason | undefined {\n\tif (raw.mergeStatus !== 'conflicts' && raw.mergeStatus !== 'failure') return undefined;\n\n\tconst previewTargetSha = raw.lastMergeTargetCommit?.commitId;\n\tif (!isCommitSha(previewTargetSha)) return 'unknown';\n\tif (!sameIdentifier(previewTargetSha, targetSha)) return undefined;\n\n\treturn raw.mergeStatus === 'conflicts' ? 'conflict' : 'unknown';\n}\n\nfunction getReportedMergeFailure(mergeStatus: AzurePullRequest['mergeStatus']): FailureReason | undefined {\n\tswitch (mergeStatus) {\n\t\tcase 'rejectedByPolicy':\n\t\t\treturn 'policy-blocked';\n\t\tcase 'conflicts':\n\t\t\treturn 'conflict';\n\t\tcase 'failure':\n\t\t\treturn 'unknown';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport class AzurePullRequestWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; accountsAuthorization: string; gitAuthorization: string },\n\t\toptions: AzurePullRequestCreateCapabilityOptions,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzurePullRequestWriter> {\n\t\tconst { body: profile } = await getAzureWriteProfile(request, credential.accessToken);\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isWriteIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('no-connection');\n\t\t}\n\n\t\tconst { body: accounts } = await getAzureWriteOrganizations(\n\t\t\trequest,\n\t\t\tcredential.accountsAuthorization,\n\t\t\taccountId,\n\t\t);\n\t\tif (!Array.isArray(accounts?.value)) throw new AzurePullRequestWriteError('unknown');\n\n\t\tconst organization = accounts.value.find(account =>\n\t\t\tsameIdentifier(account?.accountName, options.organization),\n\t\t)?.accountName;\n\t\tif (organization == null) throw new AzurePullRequestWriteError('not-found');\n\n\t\tconst headers = { Authorization: credential.gitAuthorization };\n\t\tconst { body: repo } = await request<AzureRepository>({\n\t\t\turl: `${azureBaseUrl}/${organization}/${encodeAzurePathSegment(options.project)}/_apis/git/repositories/${encodeAzurePathSegment(options.repository)}?api-version=7.1`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tif (\n\t\t\t!isAzureGuid(repo?.id) ||\n\t\t\t!isAzureGuid(repo.project?.id) ||\n\t\t\t!isPathSegment(repo.name) ||\n\t\t\t!isPathSegment(repo.project.name) ||\n\t\t\t!sameIdentifier(isAzureGuid(options.repository) ? repo.id : repo.name, options.repository) ||\n\t\t\t!sameIdentifier(isAzureGuid(options.project) ? repo.project.id : repo.project.name, options.project)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('not-found');\n\t\t}\n\t\tif (repo.isDisabled || repo.isInMaintenance) throw new AzurePullRequestWriteError('unsupported');\n\n\t\treturn new AzurePullRequestWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\taccountId,\n\t\t\t{\n\t\t\t\torganization: organization,\n\t\t\t\tprojectId: repo.project.id,\n\t\t\t\tprojectName: repo.project.name,\n\t\t\t\trepositoryId: repo.id,\n\t\t\t\trepositoryName: repo.name,\n\t\t\t},\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tstatic async connectServer(\n\t\trequest: ProviderRequestFunction,\n\t\tauthorization: string,\n\t\toptions: AzureServerPullRequestWriteScope,\n\t\troute: { collectionUrl: string; collectionBaseUrl: string },\n\t\tresolveApiVersion: () => Promise<string | undefined>,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzurePullRequestWriter> {\n\t\tconst headers = { Authorization: authorization };\n\t\tconst collection = await verifyAzureServerCollection(request, headers, route.collectionUrl, options);\n\t\tif (typeof collection === 'string') throw new AzurePullRequestWriteError(collection);\n\n\t\tconst apiVersion = await resolveApiVersion();\n\t\tif (apiVersion == null) throw new AzurePullRequestWriteError('unsupported');\n\n\t\tconst { body: repo } = await request<AzureRepository>({\n\t\t\turl: `${route.collectionUrl}/${options.projectId}/_apis/git/repositories/${encodeAzurePathSegment(options.repository)}?api-version=${apiVersion}`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tif (\n\t\t\t!isAzureGuid(repo?.id) ||\n\t\t\t!sameIdentifier(repo.project?.id, options.projectId) ||\n\t\t\t!sameIdentifier(isAzureGuid(options.repository) ? repo.id : repo.name, options.repository) ||\n\t\t\t!isPathSegment(repo.name) ||\n\t\t\t!isPathSegment(repo.project.name)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('not-found');\n\t\t}\n\t\tif (repo.isDisabled || repo.isInMaintenance) throw new AzurePullRequestWriteError('unsupported');\n\n\t\treturn new AzurePullRequestWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\tcollection.accountId,\n\t\t\t{\n\t\t\t\torganization: collection.name,\n\t\t\t\tprojectId: repo.project.id,\n\t\t\t\tprojectName: repo.project.name,\n\t\t\t\trepositoryId: repo.id,\n\t\t\t\trepositoryName: repo.name,\n\t\t\t\tserver: {\n\t\t\t\t\tproviderId: options.providerId,\n\t\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\t\tcollectionUrl: route.collectionUrl,\n\t\t\t\t\torganizationId: collection.id,\n\t\t\t\t},\n\t\t\t},\n\t\t\tisSessionCurrent,\n\t\t\troute.collectionBaseUrl,\n\t\t\tapiVersion,\n\t\t);\n\t}\n\n\tprivate readonly gitApiUrl: string;\n\tprivate readonly repoUrl: string;\n\n\tprivate constructor(\n\t\tprivate readonly request: ProviderRequestFunction,\n\t\tprivate readonly headers: { Authorization: string },\n\t\tprivate readonly accountId: string,\n\t\tprivate readonly repository: AzurePullRequestRepository,\n\t\tprivate readonly isSessionCurrent: () => Promise<boolean>,\n\t\tprivate readonly baseUrl: string = azureBaseUrl,\n\t\tprivate readonly apiVersion: string = '7.1',\n\t) {\n\t\tthis.gitApiUrl = `${baseUrl}/${encodeAzurePathSegment(repository.organization)}/${repository.projectId}/_apis/git`;\n\t\tthis.repoUrl = `${this.gitApiUrl}/repositories/${repository.repositoryId}`;\n\t}\n\n\tgetCreateCapability(): AzurePullRequestCreateCapabilityResult {\n\t\treturn { ok: true, accountId: this.accountId, repository: this.repository };\n\t}\n\n\tasync resolveTarget(number: number): Promise<AzurePullRequestWriteTargetResult> {\n\t\tif (!isPositiveInt32(number)) return { ok: false, reason: 'invalid-input' };\n\n\t\tconst { raw, pullRequest } = await this.readPullRequest(number);\n\t\tconst state = raw.status;\n\t\tconst { capability, targetSha } = await this.getCompletionTarget(raw, pullRequest);\n\t\treturn {\n\t\t\tok: true,\n\t\t\taccountId: this.accountId,\n\t\t\tpullRequest: targetSha === undefined ? pullRequest : { ...pullRequest, targetSha: targetSha },\n\t\t\tcapabilities: {\n\t\t\t\tedit: state === 'active' || state === 'abandoned',\n\t\t\t\tabandon: state === 'active',\n\t\t\t\treactivate: state === 'abandoned',\n\t\t\t\tcomplete: capability,\n\t\t\t},\n\t\t};\n\t}\n\n\tasync write(options: WriteOptions): Promise<AzurePullRequestWriteResult> {\n\t\tif (options.action === 'create') {\n\t\t\treturn this.save(options, {\n\t\t\t\tsourceRefName: options.sourceRef,\n\t\t\t\ttargetRefName: options.targetRef,\n\t\t\t\ttitle: options.title,\n\t\t\t\tdescription: options.description,\n\t\t\t});\n\t\t}\n\n\t\tconst current = await this.readPullRequest(options.number);\n\t\tconst state = current.raw.status;\n\t\tswitch (options.action) {\n\t\t\tcase 'edit':\n\t\t\t\tif (state === 'completed') return { ok: false, reason: 'conflict' };\n\n\t\t\t\treturn this.save(options, { title: options.title, description: options.description });\n\t\t\tcase 'abandon':\n\t\t\t\tif (state !== 'active') return { ok: false, reason: 'conflict' };\n\n\t\t\t\treturn this.save(options, { status: 'abandoned' });\n\t\t\tcase 'reactivate':\n\t\t\t\tif (state !== 'abandoned') return { ok: false, reason: 'conflict' };\n\n\t\t\t\treturn this.save(options, { status: 'active' });\n\t\t\tcase 'complete':\n\t\t\t\treturn this.complete(options, current.raw, current.pullRequest);\n\t\t}\n\t}\n\n\tprivate async complete(\n\t\toptions: CompletionOptions,\n\t\traw: AzurePullRequest,\n\t\tpullRequest: AzureWrittenPullRequest,\n\t): Promise<AzurePullRequestWriteResult> {\n\t\tconst failure = getCompletionRefFailure(options, pullRequest) ?? getCompletionStateFailure(raw);\n\t\tif (failure != null) return { ok: false, reason: failure };\n\n\t\tif (!this.supportedStrategies.includes(options.strategy)) return { ok: false, reason: 'unsupported' };\n\n\t\tconst strategies = await this.getAllowedStrategies(options.expectedTargetRef);\n\t\tif (!strategies.includes(options.strategy)) return { ok: false, reason: 'policy-blocked' };\n\n\t\tconst [source, target] = await this.readCompletionRefs(pullRequest);\n\t\tif (!sameIdentifier(source, options.expectedSourceSha)) return { ok: false, reason: 'source-changed' };\n\t\tif (!sameIdentifier(target, options.expectedTargetSha)) return { ok: false, reason: 'target-changed' };\n\n\t\tconst latest = await this.readPullRequest(options.number);\n\t\tconst latestFailure =\n\t\t\tgetCompletionRefFailure(options, latest.pullRequest) ?? getCompletionStateFailure(latest.raw);\n\t\tif (latestFailure != null) return { ok: false, reason: latestFailure };\n\n\t\tconst latestTarget = await this.readRef(options.expectedTargetRef);\n\t\tif (!sameIdentifier(latestTarget, options.expectedTargetSha)) {\n\t\t\treturn { ok: false, reason: 'target-changed' };\n\t\t}\n\n\t\tconst previewFailure = getMergePreviewFailure(latest.raw, options.expectedTargetSha);\n\t\tif (previewFailure != null) return { ok: false, reason: previewFailure };\n\n\t\treturn this.save(options, {\n\t\t\tstatus: 'completed',\n\t\t\tcompletionOptions:\n\t\t\t\tthis.apiVersion === '5.0'\n\t\t\t\t\t? { squashMerge: options.strategy === 'squash', bypassPolicy: false }\n\t\t\t\t\t: { mergeStrategy: options.strategy, bypassPolicy: false },\n\t\t\tlastMergeSourceCommit: { commitId: options.expectedSourceSha },\n\t\t});\n\t}\n\n\tprivate async getCompletionTarget(\n\t\traw: AzurePullRequest,\n\t\tpullRequest: AzureWrittenPullRequest,\n\t): Promise<{ capability: CompletionCapability; targetSha?: string }> {\n\t\tconst stateFailure = getCompletionStateFailure(raw);\n\t\tif (stateFailure != null) return { capability: { kind: 'unavailable', reason: stateFailure } };\n\t\tif (!pullRequest.sourceSha) return { capability: { kind: 'unavailable', reason: 'unknown' } };\n\n\t\ttry {\n\t\t\tconst strategies = await this.getAllowedStrategies(pullRequest.targetRef);\n\t\t\tif (!strategies.length) return { capability: { kind: 'unavailable', reason: 'policy-blocked' } };\n\n\t\t\tconst [source, targetSha] = await this.readCompletionRefs(pullRequest);\n\t\t\tif (!sameIdentifier(source, pullRequest.sourceSha)) {\n\t\t\t\treturn { capability: { kind: 'unavailable', reason: 'source-changed' }, targetSha: targetSha };\n\t\t\t}\n\t\t\tif (targetSha === undefined) return { capability: { kind: 'unavailable', reason: 'target-changed' } };\n\n\t\t\tconst previewFailure = getMergePreviewFailure(raw, targetSha);\n\t\t\treturn {\n\t\t\t\tcapability:\n\t\t\t\t\tpreviewFailure === undefined\n\t\t\t\t\t\t? { kind: 'available', strategies: strategies }\n\t\t\t\t\t\t: { kind: 'unavailable', reason: previewFailure },\n\t\t\t\ttargetSha: targetSha,\n\t\t\t};\n\t\t} catch (ex) {\n\t\t\treturn { capability: { kind: 'unavailable', reason: toAzurePullRequestWriteFailure(ex).reason } };\n\t\t}\n\t}\n\n\tprivate readCompletionRefs(\n\t\tpullRequest: AzureWrittenPullRequest,\n\t): Promise<[string | undefined, string | undefined]> {\n\t\treturn Promise.all([this.readRef(pullRequest.sourceRef), this.readRef(pullRequest.targetRef)]);\n\t}\n\n\tprivate get supportedStrategies(): AzurePullRequestMergeStrategy[] {\n\t\treturn this.apiVersion === '5.0' ? ['noFastForward', 'squash'] : mergeStrategies;\n\t}\n\n\tprivate async getAllowedStrategies(ref: string): Promise<AzurePullRequestMergeStrategy[]> {\n\t\tconst query = new URLSearchParams({\n\t\t\t'api-version': this.repository.server == null ? '7.1' : '5.0-preview.1',\n\t\t\trepositoryId: this.repository.repositoryId,\n\t\t\trefName: ref,\n\t\t\tpolicyType: mergeStrategyPolicyId,\n\t\t});\n\t\tlet strategies = this.supportedStrategies.slice();\n\t\tfor await (const policies of this.readPages<MergePolicy>(`${this.gitApiUrl}/policy/configurations`, query)) {\n\t\t\tfor (const policy of policies) {\n\t\t\t\tif (policy.isEnabled === true && policy.isDeleted !== true && policy.isBlocking === true) {\n\t\t\t\t\tstrategies = strategies.filter(strategy => allowsStrategy(policy, strategy));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn strategies;\n\t}\n\n\tprivate async readRef(ref: string): Promise<string | undefined> {\n\t\tconst query = new URLSearchParams({ 'api-version': this.apiVersion, filter: ref.slice('refs/'.length) });\n\t\tfor await (const refs of this.readPages<{ name: string; objectId: string }>(`${this.repoUrl}/refs`, query)) {\n\t\t\tconst match = refs.find(row => row.name === ref);\n\t\t\tif (match != null) return isCommitSha(match.objectId) ? match.objectId : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate async *readPages<T>(url: string, query: URLSearchParams): AsyncGenerator<T[]> {\n\t\tconst seen = new Set<string>();\n\t\twhile (true) {\n\t\t\tconst { body, headers } = await this.request<{ value?: T[] }>({\n\t\t\t\turl: `${url}?${query.toString()}`,\n\t\t\t\theaders: this.headers,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tif (!Array.isArray(body?.value)) throw new AzurePullRequestWriteError('unknown');\n\n\t\t\tyield body.value;\n\n\t\t\tconst next = headers['x-ms-continuationtoken'];\n\t\t\tif (!next) return;\n\t\t\tif (seen.has(next)) throw new AzurePullRequestWriteError('unknown');\n\n\t\t\tseen.add(next);\n\t\t\tquery.set('continuationToken', next);\n\t\t}\n\t}\n\n\tprivate async readPullRequest(\n\t\tnumber: number,\n\t): Promise<{ raw: AzurePullRequest; pullRequest: AzureWrittenPullRequest }> {\n\t\tconst { body: raw } = await this.request<AzurePullRequest>({\n\t\t\turl: this.pullRequestUrl(number),\n\t\t\theaders: this.headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tconst snapshot = this.toPullRequestSnapshot(raw, number);\n\t\tconst { state } = snapshot;\n\t\tif (state === undefined) {\n\t\t\tthrow new AzurePullRequestWriteError(getReportedMergeFailure(raw.mergeStatus) ?? 'unknown');\n\t\t}\n\t\treturn { raw: raw, pullRequest: { ...snapshot, state: state } };\n\t}\n\n\tprivate pullRequestUrl(number?: number): string {\n\t\treturn `${this.repoUrl}/pullrequests${number === undefined ? '' : `/${number}`}?api-version=${this.apiVersion}`;\n\t}\n\n\tprivate toPullRequestSnapshot(raw: AzurePullRequest, number?: number): PullRequestSnapshot {\n\t\tif (\n\t\t\t!sameIdentifier(raw?.repository?.id, this.repository.repositoryId) ||\n\t\t\t!sameIdentifier(raw.repository.project?.id, this.repository.projectId) ||\n\t\t\t(number !== undefined && raw.pullRequestId !== number)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('not-found');\n\t\t}\n\n\t\tif (\n\t\t\t!isPositiveInt32(raw.pullRequestId) ||\n\t\t\t(raw.status !== 'active' && raw.status !== 'abandoned' && raw.status !== 'completed') ||\n\t\t\ttypeof raw.title !== 'string' ||\n\t\t\t(raw.description != null && typeof raw.description !== 'string') ||\n\t\t\t!isBranchRef(raw.sourceRefName) ||\n\t\t\t!isBranchRef(raw.targetRefName)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('unknown');\n\t\t}\n\n\t\tconst sourceSha = raw.lastMergeSourceCommit?.commitId;\n\t\tconst targetSha = raw.lastMergeTargetCommit?.commitId;\n\t\tlet state: PullRequestSnapshot['state'] = raw.status;\n\t\tif (state === 'completed' && raw.mergeStatus !== 'succeeded') {\n\t\t\tstate = raw.mergeStatus === 'queued' ? 'active' : undefined;\n\t\t}\n\t\treturn {\n\t\t\trepository: this.repository,\n\t\t\tnumber: raw.pullRequestId,\n\t\t\turl: getAzurePullRequestWebUrl(\n\t\t\t\t{\n\t\t\t\t\tpullRequestId: raw.pullRequestId,\n\t\t\t\t\trepository: {\n\t\t\t\t\t\t...raw.repository,\n\t\t\t\t\t\tname: this.repository.repositoryName,\n\t\t\t\t\t\tproject: { id: this.repository.projectId, name: this.repository.projectName },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tthis.baseUrl,\n\t\t\t\tthis.repository.organization,\n\t\t\t),\n\t\t\ttitle: raw.title,\n\t\t\tdescription: raw.description ?? '',\n\t\t\tstate: state,\n\t\t\tsourceRef: raw.sourceRefName,\n\t\t\ttargetRef: raw.targetRefName,\n\t\t\tsourceSha: isCommitSha(sourceSha) ? sourceSha : undefined,\n\t\t\ttargetSha: isCommitSha(targetSha) ? targetSha : undefined,\n\t\t};\n\t}\n\n\tprivate async save(options: WriteOptions, body: object): Promise<AzurePullRequestWriteResult> {\n\t\tif (!(await this.isSessionCurrent())) return { ok: false, reason: 'no-connection' };\n\n\t\tconst create = options.action === 'create';\n\t\tconst number = create ? undefined : options.number;\n\t\tlet raw: AzurePullRequest;\n\t\ttry {\n\t\t\t({ body: raw } = await this.request<AzurePullRequest>({\n\t\t\t\turl: this.pullRequestUrl(number),\n\t\t\t\tmethod: create ? 'POST' : 'PATCH',\n\t\t\t\theaders: { ...this.headers, 'Content-Type': 'application/json' },\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tredirect: 'error',\n\t\t\t}));\n\t\t} catch (ex) {\n\t\t\treturn toAzurePullRequestWriteFailure(ex, { complete: options.action === 'complete' });\n\t\t}\n\n\t\tlet snapshot: PullRequestSnapshot;\n\t\ttry {\n\t\t\tsnapshot = this.toPullRequestSnapshot(raw, number);\n\t\t} catch {\n\t\t\treturn { ok: false, reason: 'outcome-unknown' };\n\t\t}\n\n\t\treturn this.getReceipt(options, raw, snapshot);\n\t}\n\n\tprivate getReceipt(\n\t\toptions: WriteOptions,\n\t\traw: AzurePullRequest,\n\t\tsnapshot: PullRequestSnapshot,\n\t): AzurePullRequestWriteResult {\n\t\tconst { state, sourceRef, targetRef } = snapshot;\n\t\tlet status: WriteStatus | undefined;\n\t\tswitch (options.action) {\n\t\t\tcase 'create':\n\t\t\t\tif (state === 'active' && sourceRef === options.sourceRef && targetRef === options.targetRef) {\n\t\t\t\t\tstatus = 'created';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'edit':\n\t\t\t\tif (\n\t\t\t\t\t(options.title === undefined || snapshot.title === options.title) &&\n\t\t\t\t\t(options.description === undefined || snapshot.description === options.description)\n\t\t\t\t) {\n\t\t\t\t\tstatus = 'updated';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'abandon':\n\t\t\t\tif (state === 'abandoned') {\n\t\t\t\t\tstatus = 'abandoned';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'reactivate':\n\t\t\t\tif (state === 'active') {\n\t\t\t\t\tstatus = 'reactivated';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'complete': {\n\t\t\t\tif (sourceRef !== options.expectedSourceRef || targetRef !== options.expectedTargetRef) break;\n\n\t\t\t\tconst failure = getReportedMergeFailure(raw.mergeStatus);\n\t\t\t\tif (failure != null) return { ok: false, reason: failure };\n\n\t\t\t\tif (state === 'active' && raw.mergeStatus === 'queued') {\n\t\t\t\t\tstatus = 'pending';\n\t\t\t\t} else if (state === 'completed') {\n\t\t\t\t\tstatus = 'completed';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn status === undefined || state === undefined\n\t\t\t? { ok: false, reason: 'outcome-unknown' }\n\t\t\t: { ok: true, status: status, pullRequest: { ...snapshot, state: state } };\n\t}\n}\n"],"mappings":";;;;;;AA0BA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;CACxB,eAAe;CACf,QAAQ;CACR,QAAQ;CACR,aAAa;AACd;AACA,MAAM,kBAAmD;CAAC;CAAiB;CAAU;CAAU;AAAa;AAkB5G,SAAS,cAAc,OAAiC;CACvD,OAAO,kBAAkB,KAAK,KAAK,UAAU,OAAO,UAAU,QAAQ,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,SAAS,IAAI;AACnH;AAEA,SAAS,YAAY,KAA6B;CACjD,OACC,OAAO,QAAQ,YACf,IAAI,WAAW,eAAe,KAC9B,IAAI,SAAS,MACb,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,MAAK,cAAa,aAAa,OAAO,YAAe,SAAS,SAAS,CAAC,KAClF,CAAC,IAAI,SAAS,IAAI,KAClB,CAAC,IAAI,SAAS,IAAI,KAClB,CAAC,IAAI,SAAS,GAAG,KACjB,IAAI,MAAM,GAAG,CAAC,CAAC,OAAM,SAAQ,KAAK,SAAS,KAAK,CAA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["import type {\n\tAzurePullRequestCreateCapabilityOptions,\n\tAzurePullRequestCreateCapabilityResult,\n\tAzurePullRequestMergeStrategy,\n\tAzurePullRequestRepository,\n\tAzurePullRequestWriteFailure,\n\tAzurePullRequestWriteOptions,\n\tAzurePullRequestWriteResult,\n\tAzurePullRequestWriteTargetResult,\n\tAzureServerPullRequestWriteOptions,\n\tAzureServerPullRequestWriteScope,\n\tAzureWrittenPullRequest,\n} from '../models/azurePullRequestWrites.js';\nimport type { AzurePullRequest, AzureRepository } from './azure/models.js';\nimport { encodeAzurePathSegment, getAzurePullRequestWebUrl } from './azure/models.js';\nimport {\n\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tverifyAzureServerCollection,\n} from './azure/writeIdentity.js';\nimport {\n\tAzurePullRequestWriteError,\n\ttoAzurePullRequestPolicyFailure,\n\ttoAzurePullRequestWriteFailure,\n} from './azurePullRequestWriteErrors.js';\nimport { isWorkItemWriteScope } from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.js';\nimport { isCommitSha, isPositiveInt32, isWriteIdentifier, sameIdentifier } from './utils/writeInputs.js';\n\nconst azureBaseUrl = 'https://dev.azure.com';\nconst branchRefPrefix = 'refs/heads/';\nconst mergeStrategyPolicyId = 'fa4e907d-c16b-4a4c-9dfa-4916e5d171ab';\nconst strategySettings = {\n\tnoFastForward: 'allowNoFastForward',\n\tsquash: 'allowSquash',\n\trebase: 'allowRebase',\n\trebaseMerge: 'allowRebaseMerge',\n} as const;\nconst mergeStrategies: AzurePullRequestMergeStrategy[] = ['noFastForward', 'squash', 'rebase', 'rebaseMerge'];\n\ntype MergePolicy = {\n\tisEnabled?: boolean;\n\tisDeleted?: boolean;\n\tisBlocking?: boolean;\n\tsettings?: Partial<Record<(typeof strategySettings)[AzurePullRequestMergeStrategy] | 'useSquashMerge', boolean>>;\n};\n\ntype CompletionCapability = Extract<AzurePullRequestWriteTargetResult, { ok: true }>['capabilities']['complete'];\ntype WriteOptions = AzurePullRequestWriteOptions | AzureServerPullRequestWriteOptions;\ntype CompletionOptions = Extract<WriteOptions, { action: 'complete' }>;\ntype FailureReason = AzurePullRequestWriteFailure['reason'];\ntype PullRequestSnapshot = Omit<AzureWrittenPullRequest, 'state'> & {\n\tstate: AzureWrittenPullRequest['state'] | undefined;\n};\ntype WriteStatus = Extract<AzurePullRequestWriteResult, { ok: true }>['status'];\n\nfunction isPathSegment(value: unknown): value is string {\n\treturn isWriteIdentifier(value) && value !== '.' && value !== '..' && !value.includes('/') && !value.includes('\\\\');\n}\n\nfunction isBranchRef(ref: unknown): ref is string {\n\treturn (\n\t\ttypeof ref === 'string' &&\n\t\tref.startsWith(branchRefPrefix) &&\n\t\tref.length > branchRefPrefix.length &&\n\t\t![...ref].some(character => character <= ' ' || '~^:?*[\\\\\\x7f'.includes(character)) &&\n\t\t!ref.includes('..') &&\n\t\t!ref.includes('@{') &&\n\t\t!ref.endsWith('.') &&\n\t\tref.split('/').every(part => part.length > 0 && !part.startsWith('.') && !part.endsWith('.lock'))\n\t);\n}\n\nexport function isAzurePullRequestScope(\n\toptions: AzurePullRequestCreateCapabilityOptions | AzureServerPullRequestWriteScope,\n): boolean {\n\tif (options.providerId === 'azure-devops-server') {\n\t\treturn isWorkItemWriteScope(options) && isPathSegment(options.repository);\n\t}\n\n\treturn (\n\t\t(options.providerId === undefined || options.providerId === 'azureDevOps') &&\n\t\tisWriteIdentifier(options.connectionId) &&\n\t\ttypeof options.organization === 'string' &&\n\t\t/^[a-z0-9][a-z0-9-]*$/i.test(options.organization) &&\n\t\tisPathSegment(options.project) &&\n\t\tisPathSegment(options.repository) &&\n\t\t(options.expectedAccountId === undefined || isWriteIdentifier(options.expectedAccountId))\n\t);\n}\n\nfunction isTitle(title: unknown): title is string {\n\treturn typeof title === 'string' && title.trim().length > 0;\n}\n\nfunction isDescription(description: unknown): boolean {\n\treturn description === undefined || (typeof description === 'string' && description.length <= 4000);\n}\n\nexport function isAzurePullRequestWrite(options: WriteOptions): boolean {\n\tif (\n\t\t(options.providerId !== undefined &&\n\t\t\toptions.providerId !== 'azureDevOps' &&\n\t\t\toptions.providerId !== 'azure-devops-server') ||\n\t\t!isAzureGuid(options.projectId) ||\n\t\t!isAzureGuid(options.repositoryId) ||\n\t\t!isWriteIdentifier(options.expectedAccountId)\n\t) {\n\t\treturn false;\n\t}\n\n\tif (options.action === 'create') {\n\t\treturn (\n\t\t\tisBranchRef(options.sourceRef) &&\n\t\t\tisBranchRef(options.targetRef) &&\n\t\t\toptions.sourceRef !== options.targetRef &&\n\t\t\tisTitle(options.title) &&\n\t\t\tisDescription(options.description)\n\t\t);\n\t}\n\n\tif (!isPositiveInt32(options.number)) return false;\n\n\tswitch (options.action) {\n\t\tcase 'edit':\n\t\t\treturn (\n\t\t\t\t(options.title !== undefined || options.description !== undefined) &&\n\t\t\t\t(options.title === undefined || isTitle(options.title)) &&\n\t\t\t\tisDescription(options.description)\n\t\t\t);\n\t\tcase 'abandon':\n\t\tcase 'reactivate':\n\t\t\treturn true;\n\t\tcase 'complete':\n\t\t\treturn (\n\t\t\t\tmergeStrategies.includes(options.strategy) &&\n\t\t\t\tisBranchRef(options.expectedSourceRef) &&\n\t\t\t\tisBranchRef(options.expectedTargetRef) &&\n\t\t\t\toptions.expectedSourceRef !== options.expectedTargetRef &&\n\t\t\t\tisCommitSha(options.expectedSourceSha) &&\n\t\t\t\tisCommitSha(options.expectedTargetSha)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction allowsStrategy(policy: MergePolicy, strategy: AzurePullRequestMergeStrategy): boolean {\n\tconst settings = policy.settings;\n\tif (settings == null) return false;\n\tif (mergeStrategies.some(type => settings[strategySettings[type]] != null)) {\n\t\treturn settings[strategySettings[strategy]] === true;\n\t}\n\n\treturn (\n\t\t(strategy === 'squash' && settings.useSquashMerge === true) ||\n\t\t(strategy === 'noFastForward' && settings.useSquashMerge === false)\n\t);\n}\n\nfunction getCompletionRefFailure(\n\toptions: CompletionOptions,\n\tpullRequest: AzureWrittenPullRequest,\n): FailureReason | undefined {\n\tif (\n\t\tpullRequest.sourceRef !== options.expectedSourceRef ||\n\t\t!sameIdentifier(pullRequest.sourceSha, options.expectedSourceSha)\n\t) {\n\t\treturn 'source-changed';\n\t}\n\tif (pullRequest.targetRef !== options.expectedTargetRef) return 'target-changed';\n\n\treturn undefined;\n}\n\nfunction getCompletionStateFailure(raw: AzurePullRequest): FailureReason | undefined {\n\tif (raw.forkSource != null) return 'unsupported';\n\tif (raw.isDraft) return 'policy-blocked';\n\tif (raw.status !== 'active' || raw.mergeStatus === 'queued') return 'conflict';\n\n\treturn undefined;\n}\n\nfunction getMergePreviewFailure(raw: AzurePullRequest, targetSha: string): FailureReason | undefined {\n\tif (raw.mergeStatus !== 'conflicts' && raw.mergeStatus !== 'failure') return undefined;\n\n\tconst previewTargetSha = raw.lastMergeTargetCommit?.commitId;\n\tif (!isCommitSha(previewTargetSha)) return 'unknown';\n\tif (!sameIdentifier(previewTargetSha, targetSha)) return undefined;\n\n\treturn raw.mergeStatus === 'conflicts' ? 'conflict' : 'unknown';\n}\n\nfunction getReportedMergeFailure(\n\traw: AzurePullRequest,\n\tsensitiveValues: readonly string[],\n): AzurePullRequestWriteFailure | undefined {\n\tswitch (raw.mergeStatus) {\n\t\tcase 'rejectedByPolicy':\n\t\t\treturn toAzurePullRequestPolicyFailure({ message: raw.mergeFailureMessage }, sensitiveValues);\n\t\tcase 'conflicts':\n\t\t\treturn { ok: false, reason: 'conflict' };\n\t\tcase 'failure':\n\t\t\treturn { ok: false, reason: 'unknown' };\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport class AzurePullRequestWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; accountsAuthorization: string; gitAuthorization: string },\n\t\toptions: AzurePullRequestCreateCapabilityOptions,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzurePullRequestWriter> {\n\t\tconst { body: profile } = await getAzureWriteProfile(request, credential.accessToken);\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isWriteIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('no-connection');\n\t\t}\n\n\t\tconst { body: accounts } = await getAzureWriteOrganizations(\n\t\t\trequest,\n\t\t\tcredential.accountsAuthorization,\n\t\t\taccountId,\n\t\t);\n\t\tif (!Array.isArray(accounts?.value)) throw new AzurePullRequestWriteError('unknown');\n\n\t\tconst organization = accounts.value.find(account =>\n\t\t\tsameIdentifier(account?.accountName, options.organization),\n\t\t)?.accountName;\n\t\tif (organization == null) throw new AzurePullRequestWriteError('not-found');\n\n\t\tconst headers = { Authorization: credential.gitAuthorization };\n\t\tconst { body: repo } = await request<AzureRepository>({\n\t\t\turl: `${azureBaseUrl}/${organization}/${encodeAzurePathSegment(options.project)}/_apis/git/repositories/${encodeAzurePathSegment(options.repository)}?api-version=7.1`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tif (\n\t\t\t!isAzureGuid(repo?.id) ||\n\t\t\t!isAzureGuid(repo.project?.id) ||\n\t\t\t!isPathSegment(repo.name) ||\n\t\t\t!isPathSegment(repo.project.name) ||\n\t\t\t!sameIdentifier(isAzureGuid(options.repository) ? repo.id : repo.name, options.repository) ||\n\t\t\t!sameIdentifier(isAzureGuid(options.project) ? repo.project.id : repo.project.name, options.project)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('not-found');\n\t\t}\n\t\tif (repo.isDisabled || repo.isInMaintenance) throw new AzurePullRequestWriteError('unsupported');\n\n\t\treturn new AzurePullRequestWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\taccountId,\n\t\t\t{\n\t\t\t\torganization: organization,\n\t\t\t\tprojectId: repo.project.id,\n\t\t\t\tprojectName: repo.project.name,\n\t\t\t\trepositoryId: repo.id,\n\t\t\t\trepositoryName: repo.name,\n\t\t\t},\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tstatic async connectServer(\n\t\trequest: ProviderRequestFunction,\n\t\tauthorization: string,\n\t\toptions: AzureServerPullRequestWriteScope,\n\t\troute: { collectionUrl: string; collectionBaseUrl: string },\n\t\tresolveApiVersion: () => Promise<string | undefined>,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzurePullRequestWriter> {\n\t\tconst headers = { Authorization: authorization };\n\t\tconst collection = await verifyAzureServerCollection(request, headers, route.collectionUrl, options);\n\t\tif (typeof collection === 'string') throw new AzurePullRequestWriteError(collection);\n\n\t\tconst apiVersion = await resolveApiVersion();\n\t\tif (apiVersion == null) throw new AzurePullRequestWriteError('unsupported');\n\n\t\tconst { body: repo } = await request<AzureRepository>({\n\t\t\turl: `${route.collectionUrl}/${options.projectId}/_apis/git/repositories/${encodeAzurePathSegment(options.repository)}?api-version=${apiVersion}`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tif (\n\t\t\t!isAzureGuid(repo?.id) ||\n\t\t\t!sameIdentifier(repo.project?.id, options.projectId) ||\n\t\t\t!sameIdentifier(isAzureGuid(options.repository) ? repo.id : repo.name, options.repository) ||\n\t\t\t!isPathSegment(repo.name) ||\n\t\t\t!isPathSegment(repo.project.name)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('not-found');\n\t\t}\n\t\tif (repo.isDisabled || repo.isInMaintenance) throw new AzurePullRequestWriteError('unsupported');\n\n\t\treturn new AzurePullRequestWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\tcollection.accountId,\n\t\t\t{\n\t\t\t\torganization: collection.name,\n\t\t\t\tprojectId: repo.project.id,\n\t\t\t\tprojectName: repo.project.name,\n\t\t\t\trepositoryId: repo.id,\n\t\t\t\trepositoryName: repo.name,\n\t\t\t\tserver: {\n\t\t\t\t\tproviderId: options.providerId,\n\t\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\t\tcollectionUrl: route.collectionUrl,\n\t\t\t\t\torganizationId: collection.id,\n\t\t\t\t},\n\t\t\t},\n\t\t\tisSessionCurrent,\n\t\t\troute.collectionBaseUrl,\n\t\t\tapiVersion,\n\t\t);\n\t}\n\n\tprivate readonly gitApiUrl: string;\n\tprivate readonly repoUrl: string;\n\tprivate readonly errorRedactions: readonly string[];\n\n\tprivate constructor(\n\t\tprivate readonly request: ProviderRequestFunction,\n\t\tprivate readonly headers: { Authorization: string },\n\t\tprivate readonly accountId: string,\n\t\tprivate readonly repository: AzurePullRequestRepository,\n\t\tprivate readonly isSessionCurrent: () => Promise<boolean>,\n\t\tprivate readonly baseUrl: string = azureBaseUrl,\n\t\tprivate readonly apiVersion: string = '7.1',\n\t) {\n\t\tconst authorization = headers.Authorization;\n\t\tconst credential = authorization.startsWith('Basic ')\n\t\t\t? atob(authorization.slice(6)).split(':').slice(1).join(':')\n\t\t\t: authorization.replace(/^Bearer /, '');\n\t\tthis.errorRedactions = [\n\t\t\tauthorization,\n\t\t\tauthorization.slice(authorization.indexOf(' ') + 1),\n\t\t\tcredential,\n\t\t\taccountId,\n\t\t];\n\t\tthis.gitApiUrl = `${baseUrl}/${encodeAzurePathSegment(repository.organization)}/${repository.projectId}/_apis/git`;\n\t\tthis.repoUrl = `${this.gitApiUrl}/repositories/${repository.repositoryId}`;\n\t}\n\n\tgetCreateCapability(): AzurePullRequestCreateCapabilityResult {\n\t\treturn { ok: true, accountId: this.accountId, repository: this.repository };\n\t}\n\n\tasync resolveTarget(number: number): Promise<AzurePullRequestWriteTargetResult> {\n\t\tif (!isPositiveInt32(number)) return { ok: false, reason: 'invalid-input' };\n\n\t\tconst { raw, pullRequest } = await this.readPullRequest(number);\n\t\tconst state = raw.status;\n\t\tconst { capability, targetSha } = await this.getCompletionTarget(raw, pullRequest);\n\t\treturn {\n\t\t\tok: true,\n\t\t\taccountId: this.accountId,\n\t\t\tpullRequest: targetSha === undefined ? pullRequest : { ...pullRequest, targetSha: targetSha },\n\t\t\tcapabilities: {\n\t\t\t\tedit: state === 'active' || state === 'abandoned',\n\t\t\t\tabandon: state === 'active',\n\t\t\t\treactivate: state === 'abandoned',\n\t\t\t\tcomplete: capability,\n\t\t\t},\n\t\t};\n\t}\n\n\tasync write(options: WriteOptions): Promise<AzurePullRequestWriteResult> {\n\t\tif (options.action === 'create') {\n\t\t\treturn this.save(options, {\n\t\t\t\tsourceRefName: options.sourceRef,\n\t\t\t\ttargetRefName: options.targetRef,\n\t\t\t\ttitle: options.title,\n\t\t\t\tdescription: options.description,\n\t\t\t});\n\t\t}\n\n\t\tconst current = await this.readPullRequest(options.number);\n\t\tconst state = current.raw.status;\n\t\tswitch (options.action) {\n\t\t\tcase 'edit':\n\t\t\t\tif (state === 'completed') return { ok: false, reason: 'conflict' };\n\n\t\t\t\treturn this.save(options, { title: options.title, description: options.description });\n\t\t\tcase 'abandon':\n\t\t\t\tif (state !== 'active') return { ok: false, reason: 'conflict' };\n\n\t\t\t\treturn this.save(options, { status: 'abandoned' });\n\t\t\tcase 'reactivate':\n\t\t\t\tif (state !== 'abandoned') return { ok: false, reason: 'conflict' };\n\n\t\t\t\treturn this.save(options, { status: 'active' });\n\t\t\tcase 'complete':\n\t\t\t\treturn this.complete(options, current.raw, current.pullRequest);\n\t\t}\n\t}\n\n\tprivate async complete(\n\t\toptions: CompletionOptions,\n\t\traw: AzurePullRequest,\n\t\tpullRequest: AzureWrittenPullRequest,\n\t): Promise<AzurePullRequestWriteResult> {\n\t\tconst failure = getCompletionRefFailure(options, pullRequest) ?? getCompletionStateFailure(raw);\n\t\tif (failure != null) return { ok: false, reason: failure };\n\n\t\tif (!this.supportedStrategies.includes(options.strategy)) return { ok: false, reason: 'unsupported' };\n\n\t\tconst strategies = await this.getAllowedStrategies(options.expectedTargetRef);\n\t\tif (!strategies.includes(options.strategy)) return { ok: false, reason: 'policy-blocked' };\n\n\t\tconst [source, target] = await this.readCompletionRefs(pullRequest);\n\t\tif (!sameIdentifier(source, options.expectedSourceSha)) return { ok: false, reason: 'source-changed' };\n\t\tif (!sameIdentifier(target, options.expectedTargetSha)) return { ok: false, reason: 'target-changed' };\n\n\t\tconst latest = await this.readPullRequest(options.number);\n\t\tconst latestFailure =\n\t\t\tgetCompletionRefFailure(options, latest.pullRequest) ?? getCompletionStateFailure(latest.raw);\n\t\tif (latestFailure != null) return { ok: false, reason: latestFailure };\n\n\t\tconst latestTarget = await this.readRef(options.expectedTargetRef);\n\t\tif (!sameIdentifier(latestTarget, options.expectedTargetSha)) {\n\t\t\treturn { ok: false, reason: 'target-changed' };\n\t\t}\n\n\t\tconst previewFailure = getMergePreviewFailure(latest.raw, options.expectedTargetSha);\n\t\tif (previewFailure != null) return { ok: false, reason: previewFailure };\n\n\t\treturn this.save(options, {\n\t\t\tstatus: 'completed',\n\t\t\tcompletionOptions:\n\t\t\t\tthis.apiVersion === '5.0'\n\t\t\t\t\t? { squashMerge: options.strategy === 'squash', bypassPolicy: false }\n\t\t\t\t\t: { mergeStrategy: options.strategy, bypassPolicy: false },\n\t\t\tlastMergeSourceCommit: { commitId: options.expectedSourceSha },\n\t\t});\n\t}\n\n\tprivate async getCompletionTarget(\n\t\traw: AzurePullRequest,\n\t\tpullRequest: AzureWrittenPullRequest,\n\t): Promise<{ capability: CompletionCapability; targetSha?: string }> {\n\t\tconst stateFailure = getCompletionStateFailure(raw);\n\t\tif (stateFailure != null) return { capability: { kind: 'unavailable', reason: stateFailure } };\n\t\tif (!pullRequest.sourceSha) return { capability: { kind: 'unavailable', reason: 'unknown' } };\n\n\t\ttry {\n\t\t\tconst strategies = await this.getAllowedStrategies(pullRequest.targetRef);\n\t\t\tif (!strategies.length) return { capability: { kind: 'unavailable', reason: 'policy-blocked' } };\n\n\t\t\tconst [source, targetSha] = await this.readCompletionRefs(pullRequest);\n\t\t\tif (!sameIdentifier(source, pullRequest.sourceSha)) {\n\t\t\t\treturn { capability: { kind: 'unavailable', reason: 'source-changed' }, targetSha: targetSha };\n\t\t\t}\n\t\t\tif (targetSha === undefined) return { capability: { kind: 'unavailable', reason: 'target-changed' } };\n\n\t\t\tconst previewFailure = getMergePreviewFailure(raw, targetSha);\n\t\t\treturn {\n\t\t\t\tcapability:\n\t\t\t\t\tpreviewFailure === undefined\n\t\t\t\t\t\t? { kind: 'available', strategies: strategies }\n\t\t\t\t\t\t: { kind: 'unavailable', reason: previewFailure },\n\t\t\t\ttargetSha: targetSha,\n\t\t\t};\n\t\t} catch (ex) {\n\t\t\treturn { capability: { kind: 'unavailable', reason: toAzurePullRequestWriteFailure(ex).reason } };\n\t\t}\n\t}\n\n\tprivate readCompletionRefs(\n\t\tpullRequest: AzureWrittenPullRequest,\n\t): Promise<[string | undefined, string | undefined]> {\n\t\treturn Promise.all([this.readRef(pullRequest.sourceRef), this.readRef(pullRequest.targetRef)]);\n\t}\n\n\tprivate get supportedStrategies(): AzurePullRequestMergeStrategy[] {\n\t\treturn this.apiVersion === '5.0' ? ['noFastForward', 'squash'] : mergeStrategies;\n\t}\n\n\tprivate async getAllowedStrategies(ref: string): Promise<AzurePullRequestMergeStrategy[]> {\n\t\tconst query = new URLSearchParams({\n\t\t\t'api-version': this.repository.server == null ? '7.1' : '5.0-preview.1',\n\t\t\trepositoryId: this.repository.repositoryId,\n\t\t\trefName: ref,\n\t\t\tpolicyType: mergeStrategyPolicyId,\n\t\t});\n\t\tlet strategies = this.supportedStrategies.slice();\n\t\tfor await (const policies of this.readPages<MergePolicy>(`${this.gitApiUrl}/policy/configurations`, query)) {\n\t\t\tfor (const policy of policies) {\n\t\t\t\tif (policy.isEnabled === true && policy.isDeleted !== true && policy.isBlocking === true) {\n\t\t\t\t\tstrategies = strategies.filter(strategy => allowsStrategy(policy, strategy));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn strategies;\n\t}\n\n\tprivate async readRef(ref: string): Promise<string | undefined> {\n\t\tconst query = new URLSearchParams({ 'api-version': this.apiVersion, filter: ref.slice('refs/'.length) });\n\t\tfor await (const refs of this.readPages<{ name: string; objectId: string }>(`${this.repoUrl}/refs`, query)) {\n\t\t\tconst match = refs.find(row => row.name === ref);\n\t\t\tif (match != null) return isCommitSha(match.objectId) ? match.objectId : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate async *readPages<T>(url: string, query: URLSearchParams): AsyncGenerator<T[]> {\n\t\tconst seen = new Set<string>();\n\t\twhile (true) {\n\t\t\tconst { body, headers } = await this.request<{ value?: T[] }>({\n\t\t\t\turl: `${url}?${query.toString()}`,\n\t\t\t\theaders: this.headers,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tif (!Array.isArray(body?.value)) throw new AzurePullRequestWriteError('unknown');\n\n\t\t\tyield body.value;\n\n\t\t\tconst next = headers['x-ms-continuationtoken'];\n\t\t\tif (!next) return;\n\t\t\tif (seen.has(next)) throw new AzurePullRequestWriteError('unknown');\n\n\t\t\tseen.add(next);\n\t\t\tquery.set('continuationToken', next);\n\t\t}\n\t}\n\n\tprivate async readPullRequest(\n\t\tnumber: number,\n\t): Promise<{ raw: AzurePullRequest; pullRequest: AzureWrittenPullRequest }> {\n\t\tconst { body: raw } = await this.request<AzurePullRequest>({\n\t\t\turl: this.pullRequestUrl(number),\n\t\t\theaders: this.headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tconst snapshot = this.toPullRequestSnapshot(raw, number);\n\t\tconst { state } = snapshot;\n\t\tif (state === undefined) {\n\t\t\tconst failure = getReportedMergeFailure(raw, this.errorRedactions);\n\t\t\tthrow new AzurePullRequestWriteError(failure?.reason ?? 'unknown', failure?.messages, failure?.policy);\n\t\t}\n\t\treturn { raw: raw, pullRequest: { ...snapshot, state: state } };\n\t}\n\n\tprivate pullRequestUrl(number?: number): string {\n\t\treturn `${this.repoUrl}/pullrequests${number === undefined ? '' : `/${number}`}?api-version=${this.apiVersion}`;\n\t}\n\n\tprivate toPullRequestSnapshot(raw: AzurePullRequest, number?: number): PullRequestSnapshot {\n\t\tif (\n\t\t\t!sameIdentifier(raw?.repository?.id, this.repository.repositoryId) ||\n\t\t\t!sameIdentifier(raw.repository.project?.id, this.repository.projectId) ||\n\t\t\t(number !== undefined && raw.pullRequestId !== number)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('not-found');\n\t\t}\n\n\t\tif (\n\t\t\t!isPositiveInt32(raw.pullRequestId) ||\n\t\t\t(raw.status !== 'active' && raw.status !== 'abandoned' && raw.status !== 'completed') ||\n\t\t\ttypeof raw.title !== 'string' ||\n\t\t\t(raw.description != null && typeof raw.description !== 'string') ||\n\t\t\t!isBranchRef(raw.sourceRefName) ||\n\t\t\t!isBranchRef(raw.targetRefName)\n\t\t) {\n\t\t\tthrow new AzurePullRequestWriteError('unknown');\n\t\t}\n\n\t\tconst sourceSha = raw.lastMergeSourceCommit?.commitId;\n\t\tconst targetSha = raw.lastMergeTargetCommit?.commitId;\n\t\tlet state: PullRequestSnapshot['state'] = raw.status;\n\t\tif (state === 'completed' && raw.mergeStatus !== 'succeeded') {\n\t\t\tstate = raw.mergeStatus === 'queued' ? 'active' : undefined;\n\t\t}\n\t\treturn {\n\t\t\trepository: this.repository,\n\t\t\tnumber: raw.pullRequestId,\n\t\t\turl: getAzurePullRequestWebUrl(\n\t\t\t\t{\n\t\t\t\t\tpullRequestId: raw.pullRequestId,\n\t\t\t\t\trepository: {\n\t\t\t\t\t\t...raw.repository,\n\t\t\t\t\t\tname: this.repository.repositoryName,\n\t\t\t\t\t\tproject: { id: this.repository.projectId, name: this.repository.projectName },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tthis.baseUrl,\n\t\t\t\tthis.repository.organization,\n\t\t\t),\n\t\t\ttitle: raw.title,\n\t\t\tdescription: raw.description ?? '',\n\t\t\tstate: state,\n\t\t\tsourceRef: raw.sourceRefName,\n\t\t\ttargetRef: raw.targetRefName,\n\t\t\tsourceSha: isCommitSha(sourceSha) ? sourceSha : undefined,\n\t\t\ttargetSha: isCommitSha(targetSha) ? targetSha : undefined,\n\t\t};\n\t}\n\n\tprivate async save(options: WriteOptions, body: object): Promise<AzurePullRequestWriteResult> {\n\t\tif (!(await this.isSessionCurrent())) return { ok: false, reason: 'no-connection' };\n\n\t\tconst create = options.action === 'create';\n\t\tconst number = create ? undefined : options.number;\n\t\tlet raw: AzurePullRequest;\n\t\ttry {\n\t\t\t({ body: raw } = await this.request<AzurePullRequest>({\n\t\t\t\turl: this.pullRequestUrl(number),\n\t\t\t\tmethod: create ? 'POST' : 'PATCH',\n\t\t\t\theaders: { ...this.headers, 'Content-Type': 'application/json' },\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tredirect: 'error',\n\t\t\t}));\n\t\t} catch (ex) {\n\t\t\treturn toAzurePullRequestWriteFailure(\n\t\t\t\tex,\n\t\t\t\t{ complete: options.action === 'complete' },\n\t\t\t\tthis.errorRedactions,\n\t\t\t);\n\t\t}\n\n\t\tlet snapshot: PullRequestSnapshot;\n\t\ttry {\n\t\t\tsnapshot = this.toPullRequestSnapshot(raw, number);\n\t\t} catch {\n\t\t\treturn { ok: false, reason: 'outcome-unknown' };\n\t\t}\n\n\t\treturn this.getReceipt(options, raw, snapshot);\n\t}\n\n\tprivate getReceipt(\n\t\toptions: WriteOptions,\n\t\traw: AzurePullRequest,\n\t\tsnapshot: PullRequestSnapshot,\n\t): AzurePullRequestWriteResult {\n\t\tconst { state, sourceRef, targetRef } = snapshot;\n\t\tlet status: WriteStatus | undefined;\n\t\tswitch (options.action) {\n\t\t\tcase 'create':\n\t\t\t\tif (state === 'active' && sourceRef === options.sourceRef && targetRef === options.targetRef) {\n\t\t\t\t\tstatus = 'created';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'edit':\n\t\t\t\tif (\n\t\t\t\t\t(options.title === undefined || snapshot.title === options.title) &&\n\t\t\t\t\t(options.description === undefined || snapshot.description === options.description)\n\t\t\t\t) {\n\t\t\t\t\tstatus = 'updated';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'abandon':\n\t\t\t\tif (state === 'abandoned') {\n\t\t\t\t\tstatus = 'abandoned';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'reactivate':\n\t\t\t\tif (state === 'active') {\n\t\t\t\t\tstatus = 'reactivated';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'complete': {\n\t\t\t\tif (sourceRef !== options.expectedSourceRef || targetRef !== options.expectedTargetRef) break;\n\n\t\t\t\tconst failure = getReportedMergeFailure(raw, this.errorRedactions);\n\t\t\t\tif (failure != null) return failure;\n\n\t\t\t\tif (state === 'active' && raw.mergeStatus === 'queued') {\n\t\t\t\t\tstatus = 'pending';\n\t\t\t\t} else if (state === 'completed') {\n\t\t\t\t\tstatus = 'completed';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn status === undefined || state === undefined\n\t\t\t? { ok: false, reason: 'outcome-unknown' }\n\t\t\t: { ok: true, status: status, pullRequest: { ...snapshot, state: state } };\n\t}\n}\n"],"mappings":";;;;;;AA8BA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;CACxB,eAAe;CACf,QAAQ;CACR,QAAQ;CACR,aAAa;AACd;AACA,MAAM,kBAAmD;CAAC;CAAiB;CAAU;CAAU;AAAa;AAkB5G,SAAS,cAAc,OAAiC;CACvD,OAAO,kBAAkB,KAAK,KAAK,UAAU,OAAO,UAAU,QAAQ,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,SAAS,IAAI;AACnH;AAEA,SAAS,YAAY,KAA6B;CACjD,OACC,OAAO,QAAQ,YACf,IAAI,WAAW,eAAe,KAC9B,IAAI,SAAS,MACb,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,MAAK,cAAa,aAAa,OAAO,YAAe,SAAS,SAAS,CAAC,KAClF,CAAC,IAAI,SAAS,IAAI,KAClB,CAAC,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AK;IACJ,IAAI,UAAU,aACb,SAAS;IAEV;GACD,KAAK;IACJ,IAAI,UAAU,UACb,SAAS;IAEV;GACD,KAAK,YAAY;IAChB,IAAI,cAAc,QAAQ,qBAAqB,cAAc,QAAQ,mBAAmB;IAExF,MAAM,UAAU,wBAAwB,KAAK,KAAK,eAAe;IACjE,IAAI,WAAW,MAAM,OAAO;IAE5B,IAAI,UAAU,YAAY,IAAI,gBAAgB,UAC7C,SAAS;SACH,IAAI,UAAU,aACpB,SAAS;IAEV;GACD;EACD;EAEA,OAAO,WAAW,KAAA,KAAa,UAAU,KAAA,IACtC;GAAE,IAAI;GAAO,QAAQ;EAAkB,IACvC;GAAE,IAAI;GAAc;GAAQ,aAAa;IAAE,GAAG;IAAiB;GAAM;EAAE;CAC3E;AACD"}
|
|
@@ -2,9 +2,9 @@ import { chunk } from "../../../utils/array.js";
|
|
|
2
2
|
import { isCancellationError } from "../../../utils/cancellation.js";
|
|
3
3
|
import { batch, mapBounded, mapSettledBounded } from "../../../utils/promise.js";
|
|
4
4
|
import { AuthenticationError, RequestNotFoundError } from "../../../git/errors.js";
|
|
5
|
-
import { uuid } from "../../../utils/crypto.js";
|
|
6
5
|
import { parseGitRemoteUrl } from "../../../git/utils/remote.utils.js";
|
|
7
6
|
import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
|
|
7
|
+
import { uuid } from "../../../utils/crypto.js";
|
|
8
8
|
import "../../../git/models/pullRequest.js";
|
|
9
9
|
import { decodeGitHubCheckRunId, fromGitHubCheckContextState, fromGitHubIssueOrPullRequestState, fromGitHubMergeQueueEntryState, fromGitHubMergeQueueRemoval, fromGitHubPullRequestMergeableState, fromGitHubPullRequestReviewDecision, fromGitHubPullRequestStatusCheckRollupState, toGitHubCheckRunId } from "../../git-github/models.js";
|
|
10
10
|
import { IntegrationReadUnavailableError } from "../errors.js";
|
|
@@ -7,8 +7,10 @@ import { Account } from "../../../git/models/author.js";
|
|
|
7
7
|
import { ProviderAuthenticationSession } from "../authentication/models.js";
|
|
8
8
|
import { IssuesSelfManagedHostIntegrationId } from "../constants.js";
|
|
9
9
|
import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
|
|
10
|
+
import { IssueTrackerWriteConnection } from "../models/issueTrackerWrites.js";
|
|
10
11
|
import { IntegrationKey } from "../models/publicIntegration.js";
|
|
11
12
|
import { IntegrationServiceContext } from "../context.js";
|
|
13
|
+
import { JiraIssueWriter } from "./jiraIssueWrites.js";
|
|
12
14
|
import { ProvidersApi } from "./providersApi.js";
|
|
13
15
|
import { AccountWideIssuesResult, IssuesForProjectOptions, ProjectIssuesDrain, ProjectIssuesRequest, SearchMyIssuesOptions } from "../models/issueReads.js";
|
|
14
16
|
import { IssuesIntegration } from "../models/issuesIntegration.js";
|
|
@@ -39,6 +41,13 @@ export declare class JiraServerIntegration extends IssuesIntegration<IssuesSelfM
|
|
|
39
41
|
readonly name: string;
|
|
40
42
|
constructor(ctx: IntegrationServiceContext, authenticationService: IntegrationAuthenticationService, getProvidersApi: () => Promise<ProvidersApi>, didChangeConnection: Emitter<IntegrationConnectionChangeEvent>, _domain: string);
|
|
41
43
|
get domain(): string;
|
|
44
|
+
protected getSessionFingerprint(session: ProviderAuthenticationSession): string;
|
|
45
|
+
getIssueWriter(options: Extract<IssueTrackerWriteConnection, {
|
|
46
|
+
providerId: IssuesSelfManagedHostIntegrationId.JiraServer;
|
|
47
|
+
}>, session: ProviderAuthenticationSession, isSelectionCurrent: () => boolean): Promise<{
|
|
48
|
+
writer: JiraIssueWriter;
|
|
49
|
+
isCurrent: () => boolean;
|
|
50
|
+
}>;
|
|
42
51
|
/**
|
|
43
52
|
* The URL every request for this connection is addressed to, built from the SESSION's domain rather than
|
|
44
53
|
* the integration's.
|
|
@@ -61,6 +70,7 @@ export declare class JiraServerIntegration extends IssuesIntegration<IssuesSelfM
|
|
|
61
70
|
autolinks(): Promise<AutolinkReference[]>;
|
|
62
71
|
private buildAutolinks;
|
|
63
72
|
private buildAutolinksCore;
|
|
73
|
+
protected getProviderCurrentAccount(session: ProviderAuthenticationSession): Promise<Account | undefined>;
|
|
64
74
|
protected getProviderAccountForResource(session: ProviderAuthenticationSession, _resource: JiraServerResourceDescriptor): Promise<Account | undefined>;
|
|
65
75
|
protected getProviderResourcesForUser(session: ProviderAuthenticationSession, _force?: boolean): Promise<JiraServerResourceDescriptor[] | undefined>;
|
|
66
76
|
/** Expires, and is dropped on a re-sync, so a project created or deleted mid-session is picked up (#5907). */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Logger as _logger } from "../../../utils/logger.js";
|
|
2
|
+
import { fnv1aHash64 } from "../../../utils/hash.js";
|
|
2
3
|
import "../constants.js";
|
|
3
4
|
import { isJiraServerMissingProjectError } from "./providerErrors.js";
|
|
4
5
|
import { isIncompleteCollection, toCollectionScopeFailure } from "../collectionMetadata.js";
|
|
5
6
|
import { mergeCollectionMetadata } from "./utils/providerPaging.js";
|
|
6
7
|
import { providersMetadata } from "./metadata.js";
|
|
7
8
|
import { areDomainsOnSameHost, baseUrlFromDomain } from "../utils/domain.utils.js";
|
|
8
|
-
import { toTokenWithInfo } from "../authentication/models.js";
|
|
9
|
+
import { sessionExpiry, toTokenWithInfo } from "../authentication/models.js";
|
|
9
10
|
import { toAccount, toIssueShape, toProviderIssueStates } from "./models.js";
|
|
10
11
|
import { createIssueAutolinkReferences } from "./utils/issueAutolinks.js";
|
|
11
12
|
import { IssuesIntegration, groupProjectIssuesSearches, toProjectsCollection } from "../models/issuesIntegration.js";
|
|
@@ -60,6 +61,17 @@ var JiraServerIntegration = class extends IssuesIntegration {
|
|
|
60
61
|
get domain() {
|
|
61
62
|
return this._domain;
|
|
62
63
|
}
|
|
64
|
+
getSessionFingerprint(session) {
|
|
65
|
+
return fnv1aHash64(JSON.stringify([this.apiBaseUrlFor(session), session.accessToken]));
|
|
66
|
+
}
|
|
67
|
+
async getIssueWriter(options, session, isSelectionCurrent) {
|
|
68
|
+
const isSessionCurrent = this.authenticationService.trackStoredSession(this.id, session, true);
|
|
69
|
+
const isCurrent = () => isSelectionCurrent() && this.isIntegrationAccessEnabled() && !isSessionCurrent.isRetired() && sessionExpiry(session.expiresAt) > Date.now();
|
|
70
|
+
return {
|
|
71
|
+
writer: await (await this.getProvidersApi()).getJiraServerIssueWriter(options, session, isCurrent, isSessionCurrent, () => this.getIgnoreSSLErrors()),
|
|
72
|
+
isCurrent
|
|
73
|
+
};
|
|
74
|
+
}
|
|
63
75
|
/**
|
|
64
76
|
* The URL every request for this connection is addressed to, built from the SESSION's domain rather than
|
|
65
77
|
* the integration's.
|
|
@@ -136,6 +148,9 @@ var JiraServerIntegration = class extends IssuesIntegration {
|
|
|
136
148
|
return this._autolinks.get(cacheKey)?.autolinks ?? [];
|
|
137
149
|
}
|
|
138
150
|
}
|
|
151
|
+
getProviderCurrentAccount(session) {
|
|
152
|
+
return this.getProviderAccountForResource(session, this.resourceFor(session));
|
|
153
|
+
}
|
|
139
154
|
async getProviderAccountForResource(session, _resource) {
|
|
140
155
|
const user = await (await this.getProvidersApi()).getJiraServerCurrentUser(toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session));
|
|
141
156
|
if (user == null) return void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jira-server.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jira-server.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueProjection, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { isIncompleteCollection, toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesSelfManagedHostIntegrationId } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport { groupProjectIssuesSearches, IssuesIntegration, toProjectsCollection } from '../models/issuesIntegration.js';\nimport type { IntegrationKey } from '../models/publicIntegration.js';\nimport { areDomainsOnSameHost, baseUrlFromDomain } from '../utils/domain.utils.js';\nimport { providersMetadata } from './metadata.js';\nimport type { ProviderApiCollectionResult } from './models.js';\nimport { toAccount, toIssueShape, toProviderIssueStates } from './models.js';\nimport { isJiraServerMissingProjectError } from './providerErrors.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport { DiscoveryCache, discoveryCacheTtl } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\tsummarizePageMetadata,\n\ttoUniqueJiraIssueShapes,\n\twithFailureScope,\n} from './utils/jiraIssueDrains.js';\nimport { mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesSelfManagedHostIntegrationId.JiraServer];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n\n/**\n * Every clause is scoped by the HANDLE, and `options.userId` is deliberately ignored here — the one\n * place this provider diverges from Jira Cloud's, which applies it to `assignee`/`creator` (#5857).\n *\n * The two are not interchangeable because `Account.id` means something different per deployment. On\n * Cloud it is the `accountId`, which JQL resolves, so scoping by it fixes the deactivated-account case\n * where the display name no longer resolves. On Server it is the user KEY (`JIRAUSER10224`), which JQL\n * does not resolve at all: measured against a live Jira Server 8.20.13 site, `assignee in\n * (\"JIRAUSER10224\")` returns 0 with `\"The value 'JIRAUSER10224' does not exist for the field\n * 'assignee'\"` — the identical warning a genuinely nonexistent user produces — while the username and\n * the display name both return the real 4.\n *\n * So applying `userId` here would silently empty the read rather than harden it. Do not \"fix\" this\n * asymmetry to match Cloud without re-measuring against a Server instance.\n *\n * The handle itself is already the right one: `provider-apis` 0.60.0 maps `Account.username` from the\n * Server payload's `name` (falling back to `displayName` when absent), so these clauses are scoped by the\n * real username rather than a display name (GKDEV-3629). That is what makes the `mention` clause work at\n * all — it is a free-text `comment ~ \"...\"` over comment bodies, and a Jira mention is stored as\n * `[~username]`, which a display name never matches.\n */\nfunction toUserIdentities(user: string): { userField: string; mention: string } {\n\treturn { userField: user, mention: user };\n}\n\n/**\n * The single resource a Jira Server connection has: the instance itself.\n *\n * Jira Cloud's account spans many sites, so its resources come from an API call that lists them. A\n * self-hosted instance IS the one site the connection addresses, so there is nothing to enumerate — this\n * descriptor is synthesized from the configured host. Modelling it as a resource anyway keeps the\n * resource → project contract of {@link IssuesIntegration} intact, so every tracker read (`listOrgs`,\n * `listProjects`, `listIssueTrackerIssuesPage`) works unchanged.\n */\nexport interface JiraServerResourceDescriptor extends IssueResourceDescriptor {\n\turl: string;\n}\n\nexport interface JiraServerProjectDescriptor extends IssueResourceDescriptor {\n\tresourceId: string;\n}\n\nexport class JiraServerIntegration extends IssuesIntegration<IssuesSelfManagedHostIntegrationId.JiraServer> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = IssuesSelfManagedHostIntegrationId.JiraServer;\n\tprotected readonly key: IntegrationKey<IssuesSelfManagedHostIntegrationId.JiraServer>;\n\treadonly name: string = 'Jira Data Center';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t\tthis.key = `${this.id}:${this._domain}`;\n\t}\n\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\n\t/**\n\t * The URL every request for this connection is addressed to, built from the SESSION's domain rather than\n\t * the integration's.\n\t *\n\t * `this.domain` is the host-keyed identity — `IntegrationService.get()` runs it through `hostFromDomain`\n\t * so one host can't build two instances — which means it has had any context path stripped, and so has\n\t * `session.domain`, which is stored as that same normalized host. Jira Data Center officially supports\n\t * being mounted below a context path (`https://jira.example.com/jira`), so the address comes from\n\t * {@link ProviderAuthenticationSession.baseUrl}, which carries the configured value verbatim; it falls\n\t * back to the host when the backend reported nothing more, which is the common case.\n\t *\n\t * Takes the session rather than reading `_session` so a per-connection (multi-account) read is addressed\n\t * to the host of the connection it resolved, not to whichever one happens to be current.\n\t */\n\tprotected apiBaseUrlFor(session: ProviderAuthenticationSession | undefined): string {\n\t\tconst configured = baseUrlFromDomain(session?.baseUrl, session?.protocol);\n\t\t// A `baseUrl` from another host is not this connection's address — refuse it rather than routing this\n\t\t// integration's reads somewhere its key never named.\n\t\tif (configured != null && areDomainsOnSameHost(session?.baseUrl, this.domain)) return configured;\n\n\t\treturn (\n\t\t\tbaseUrlFromDomain(session?.domain, session?.protocol) ??\n\t\t\tbaseUrlFromDomain(this.domain, session?.protocol) ??\n\t\t\t`${session?.protocol ?? 'https:'}//${this.domain}`\n\t\t);\n\t}\n\n\t/** The one resource this connection has — see {@link JiraServerResourceDescriptor}. */\n\tprivate resourceFor(session: ProviderAuthenticationSession | undefined): JiraServerResourceDescriptor {\n\t\treturn { id: this.domain, key: this.domain, name: this.domain, url: this.apiBaseUrlFor(session) };\n\t}\n\n\tprivate readonly _autolinks = new Map<string, { autolinks: AutolinkReference[]; builtAt: number }>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<AutolinkReference[]>>();\n\n\toverride async autolinks(): Promise<AutolinkReference[]> {\n\t\tconst generation = this.discoveryGeneration;\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) return [];\n\t\tif (!this.isResolvedSessionCurrent(this._session, generation)) return [];\n\n\t\tconst session = this._session;\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tconst cached = this._autolinks.get(cacheKey);\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (Date.now() - cached.builtAt >= discoveryCacheTtl) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\tprivate buildAutolinks(session: ProviderAuthenticationSession): Promise<AutolinkReference[]> {\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tlet build = this._autolinksBuilds.get(cacheKey);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session).finally(() => {\n\t\t\t\tif (this._autolinksBuilds.get(cacheKey) === build) {\n\t\t\t\t\tthis._autolinksBuilds.delete(cacheKey);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._autolinksBuilds.set(cacheKey, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(session: ProviderAuthenticationSession): Promise<AutolinkReference[]> {\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tconst generation = this._projects.generation;\n\t\ttry {\n\t\t\tconst resource = this.resourceFor(session);\n\t\t\tconst result = await this.getProjectsForResourcesWithMetadataResult([resource]);\n\t\t\tif (this._projects.generation !== generation) return [];\n\t\t\tif (result?.value == null || result.error != null || isIncompleteCollection(result.value.metadata)) {\n\t\t\t\treturn this._autolinks.get(cacheKey)?.autolinks ?? [];\n\t\t\t}\n\n\t\t\tconst autolinks: AutolinkReference[] = [];\n\t\t\tfor (const project of result.value.values) {\n\t\t\t\tif (project.key === project.id) continue;\n\n\t\t\t\tautolinks.push(\n\t\t\t\t\t...createIssueAutolinkReferences(\n\t\t\t\t\t\tproject.key,\n\t\t\t\t\t\t`${resource.url}/browse/${project.key}-<num>`,\n\t\t\t\t\t\tresource,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._autolinks.set(cacheKey, { autolinks: autolinks, builtAt: Date.now() });\n\t\t\treturn autolinks;\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, 'JiraServerIntegration.autolinks');\n\t\t\treturn this._autolinks.get(cacheKey)?.autolinks ?? [];\n\t\t}\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: JiraServerResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getJiraServerCurrentUser(toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session));\n\n\t\tif (user == null) return undefined;\n\t\treturn toAccount(user, this);\n\t}\n\n\tprotected override getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_force?: boolean,\n\t): Promise<JiraServerResourceDescriptor[] | undefined> {\n\t\t// Synthesized from the configured host rather than fetched, so there is nothing to cache or force.\n\t\treturn Promise.resolve([this.resourceFor(session)]);\n\t}\n\n\t/** Expires, and is dropped on a re-sync, so a project created or deleted mid-session is picked up (#5907). */\n\tprivate readonly _projects = new DiscoveryCache<JiraServerProjectDescriptor[]>();\n\tprivate readonly _projectReads = new Map<string, Promise<JiraServerProjectDescriptor[] | undefined>>();\n\tprotected override getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraServerResourceDescriptor[],\n\t): Promise<JiraServerProjectDescriptor[] | undefined> {\n\t\t// Every resource here is this instance (see `getProviderResourcesForUser`), so one read serves them\n\t\t// all; a caller that passes none is asking for nothing.\n\t\tif (resources.length === 0) return Promise.resolve([]);\n\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tconst cached = this._projects.get(cacheKey);\n\t\tif (cached != null) return Promise.resolve(cached);\n\n\t\tlet read = this._projectReads.get(cacheKey);\n\t\tif (read == null) {\n\t\t\tread = this.readProjectsCached(session, cacheKey).finally(() => {\n\t\t\t\tif (this._projectReads.get(cacheKey) === read) {\n\t\t\t\t\tthis._projectReads.delete(cacheKey);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._projectReads.set(cacheKey, read);\n\t\t}\n\t\treturn read;\n\t}\n\n\tprivate async readProjectsCached(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcacheKey: string,\n\t): Promise<JiraServerProjectDescriptor[] | undefined> {\n\t\tconst generation = this._projects.generation;\n\t\tconst descriptors = await this.readProjects(session);\n\t\tif (descriptors == null) return undefined;\n\n\t\tif (this._projects.set(cacheKey, descriptors, { generation: generation }) !== false) {\n\t\t\tthis._autolinks.delete(cacheKey);\n\t\t}\n\n\t\treturn descriptors;\n\t}\n\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraServerResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<JiraServerProjectDescriptor>> {\n\t\tif (resources.length === 0) return { values: [] };\n\n\t\treturn toProjectsCollection(await this.readProjects(session));\n\t}\n\n\tprivate async readProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraServerProjectDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst projects = await api.getJiraServerProjects(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t\tif (projects == null) return undefined;\n\t\tif (projects.length === 0) {\n\t\t\t// Jira can serve anonymous empty projects after rejection without an identifying response header.\n\t\t\tconst account = await this.getProviderAccountForResource(session, this.resourceFor(session));\n\t\t\tif ((account?.username ?? account?.name) == null) return undefined;\n\t\t}\n\n\t\tconst resourceId = this.resourceFor(session).id;\n\t\treturn projects.map<JiraServerProjectDescriptor>(p => ({\n\t\t\tid: p.id,\n\t\t\t// The project key, which selects the project (`listProjects`' `name`) and is what an issue key starts\n\t\t\t// with. The SDK does not validate it, so a missing or blank one falls back to the numeric id, never to the\n\t\t\t// display name, which can equal another project's key. The reads below still address the project by\n\t\t\t// `id`, which no other project can share.\n\t\t\tkey: p.key?.trim() || p.id,\n\t\t\tname: p.name,\n\t\t\tresourceId: resourceId,\n\t\t}));\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraServerProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraServerProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\n\t\t// The same drain as Jira Cloud's (`jiraIssueDrains.ts`): page to a defensive backstop, and report `truncated`\n\t\t// plus a structured failure rather than discarding an already-fetched prefix.\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\t// The numeric project id, not the name: JQL resolves `project = \"<value>\"` against key first, so a display\n\t\t// name that matches another project's key reads that project's issues instead. A Jira project key must begin\n\t\t// with a letter, so a purely numeric value can only be an id.\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getJiraServerIssuesForProjectPaged(tokenWithInfo, baseUrl, project.id, {\n\t\t\t\t...scope,\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t\tsort: options?.sort,\n\t\t\t});\n\t\tconst drainOptions: JiraDrainOptions = {\n\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\t// Scoped by key, as on Jira Cloud: the id addresses the read, the key is how a consumer names the project.\n\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId, projectId: project.key },\n\t\t\tproviderName: 'Jira Server',\n\t\t\t// A project this connection can no longer see (deleted, or its browse permission removed) holds\n\t\t\t// no issues for it, and the project list that named it is stale: drop that list so the next read\n\t\t\t// re-reads it, instead of failing the whole provider on every read until a restart (#5907).\n\t\t\tisEmptyFailure: ex => {\n\t\t\t\tif (!isJiraServerMissingProjectError(ex)) return false;\n\n\t\t\t\tLogger.warn(`Jira Server project '${project.name}' (${project.id}) no longer exists or is not visible`);\n\t\t\t\tthis.invalidateDiscoveryCaches();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\n\t\tif (options?.user != null) {\n\t\t\tconst read = await readUserScopedJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\toptions.filters,\n\t\t\t\ttoUserIdentities(options.user),\n\t\t\t\tdrainOptions,\n\t\t\t);\n\t\t\tconst values = toUniqueJiraIssueShapes(read.issues, this);\n\t\t\tconst drain = { values: values, metadata: read.metadata, scope: drainOptions.failureScope };\n\t\t\t// `recovery: 'none'` for the whole set: the filter branches merge here, so even a pure backstop in one\n\t\t\t// branch is not fixable by narrowing this read's scope.\n\t\t\treturn read.truncated ? { ...drain, truncated: true, recovery: 'none' } : { ...drain, truncated: false };\n\t\t}\n\n\t\tconst unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);\n\t\tconst values = unscoped.issues\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'project' }))\n\t\t\t.filter((result): result is IssueShape => result !== undefined);\n\t\tconst drain = { values: values, metadata: unscoped.metadata, scope: drainOptions.failureScope };\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? { ...drain, truncated: true, recovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none' }\n\t\t\t: { ...drain, truncated: false };\n\t}\n\n\t/**\n\t * Searches the instance's projects together for a user-scoped read, as Jira Cloud does per site: one JQL names\n\t * up to {@link JIRA_MAX_PROJECT_KEYS_PER_REQUEST} projects of one user scope. An unscoped read stays per project,\n\t * since its backstop is reported as `narrow-scope` per project.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<JiraServerProjectDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(\n\t\t\trequests,\n\t\t\t({ options }) =>\n\t\t\t\toptions.user != null\n\t\t\t\t\t? [options.user, options.sort ?? '', options.state ?? '', options.filters?.join(',') ?? ''].join(\n\t\t\t\t\t\t\t'\\0',\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined,\n\t\t\tJIRA_MAX_PROJECT_KEYS_PER_REQUEST,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<JiraServerProjectDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares its user scope (see `getProjectIssuesSearches`).\n\t\tconst { options } = requests[0];\n\t\tif (options.user == null) return undefined;\n\t\t// One project's search is its own read, by the same numeric id, so it costs no more to read it as one. And it\n\t\t// reports what the search can't: a dropped issue's failure, which a search can only answer by being read again.\n\t\tif (requests.length === 1) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\t// By numeric id, as the per-project read names them (see there).\n\t\tconst projectIds = requests.map(request => request.project.id);\n\t\tconst states = toProviderIssueStates(options.state);\n\n\t\treturn searchJiraProjectIssues(\n\t\t\t(userScope, cursor) =>\n\t\t\t\tapi.getJiraServerIssuesForProjectsPaged(tokenWithInfo, baseUrl, projectIds, {\n\t\t\t\t\t...userScope,\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tstates: states,\n\t\t\t\t\tsort: options.sort,\n\t\t\t\t}),\n\t\t\tprojectIds,\n\t\t\toptions.filters,\n\t\t\ttoUserIdentities(options.user),\n\t\t\t{ maxPages: maxPagesPerRequest, failureScope: { providerId: this.id }, providerName: 'Jira Server' },\n\t\t\tthis,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraServerResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * Account-wide \"my issues\" for this instance, drained to the backstop and reporting whether it got there.\n\t *\n\t * The override exists for the same reason the project drain reports `status`: the default\n\t * implementation wraps whatever the normalized read returned as `truncated: false`, so a run that stopped\n\t * at `maxPagesPerRequest` with pages left, or on a continuation the server never advanced, would be\n\t * published as a complete account. Cancellation is NOT truncation — the caller asked for the stop and\n\t * already knows the prefix is partial — so it breaks without setting the flag.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources?: JiraServerResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\n\t\t// Errors propagate, unlike Jira Cloud's sibling. Cloud swallows per resource because it loops over the\n\t\t// account's many sites and one bad site must not discard the others; this connection addresses exactly\n\t\t// one instance, so there is no sibling to protect and swallowing would turn every failure — an expired\n\t\t// token, an unreachable host — into an empty success. `searchMyIssuesWithTruncationResult` recovers the\n\t\t// throw into `{ error }`, which is what lets the caller warn instead of reporting \"no issues\".\n\t\t// Only the provider: the instance is this connection's single resource, so naming it would publish a\n\t\t// failure of the whole connection as one confined to a sub-scope (see `ProviderWarning.scope`).\n\t\tconst accountScope = { providerId: this.id };\n\t\tconst results: IssueShape[] = [];\n\t\tlet cursor: string | undefined;\n\t\tlet truncated = false;\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tconst pages: CollectionMetadata[] = [];\n\n\t\tconst stopIncomplete = (reason: string) => {\n\t\t\ttruncated = true;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\tcompleteness: 'partial',\n\t\t\t\tfailures: [toCollectionScopeFailure(accountScope, new Error(reason))],\n\t\t\t});\n\t\t};\n\n\t\tfor (let i = 0; i < maxPagesPerRequest; i++) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst page = await api.getJiraServerIssuesForCurrentUser(tokenWithInfo, baseUrl, {\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t});\n\t\t\tif (page == null) {\n\t\t\t\t// Nothing fetched yet and no page is an empty account, not a failure; after a continuation it\n\t\t\t\t// means the server dropped the drain mid-way.\n\t\t\t\tif (cursor != null) {\n\t\t\t\t\tstopIncomplete('Jira Server returned no page after advertising a continuation');\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tresults.push(\n\t\t\t\t...page.data\n\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t.filter((r): r is IssueShape => r != null),\n\t\t\t);\n\t\t\t// An issue the page dropped because it could not be read arrives here, not as a missing row; recorded under\n\t\t\t// the same scope as this read's other failures.\n\t\t\tif (page.metadata != null) {\n\t\t\t\t// Truncated too, as Jira Cloud's read is through `getPagedResult`: the account is missing that issue.\n\t\t\t\ttruncated ||= isIncompleteCollection(page.metadata);\n\t\t\t\tpages.push(withFailureScope(page.metadata, accountScope));\n\t\t\t}\n\n\t\t\tif (!page.hasMore) break;\n\n\t\t\t// More pages are claimed but no advancing cursor came back: the drain can't continue, so flag it\n\t\t\t// rather than stopping silently.\n\t\t\tif (page.nextCursor == null || page.nextCursor === cursor) {\n\t\t\t\tstopIncomplete('Jira Server returned no advancing issue continuation');\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcursor = page.nextCursor;\n\t\t\t// Pages remain but this was the last allowed iteration: the backstop stopped the drain.\n\t\t\tif (i === maxPagesPerRequest - 1) {\n\t\t\t\tstopIncomplete(\n\t\t\t\t\t`Jira Server account-wide issue drain stopped at the ${maxPagesPerRequest}-page backstop`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: results,\n\t\t\ttruncated: truncated,\n\t\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t\t};\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: JiraServerResourceDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getJiraServerIssue(toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session), key);\n\t\treturn issue != null ? toIssueShape(issue, this, { projection: 'point' }) : undefined;\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: JiraServerResourceDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\treturn this.readIssue(session, id, 'point');\n\t}\n\n\tprivate async readIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tid: string,\n\t\tprojection: IssueProjection,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getJiraServerIssue(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tid,\n\t\t);\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: projection }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\t/**\n\t * The point read behind `getIssuesBatch`'s tracker targets (#5872). `resourceId` is this connection's single\n\t * synthetic resource — the host itself, see {@link JiraServerResourceDescriptor} — so it selects nothing further\n\t * here: the host was chosen upstream by `domain` (or the connection's configured domain) and the request is\n\t * addressed to the SESSION's base URL like every other read. No `resourceUrl` is needed either, unlike Jira\n\t * Cloud: its REST `self` link is an API endpoint, whereas `getJiraServerIssue` builds the browser link from\n\t * the base URL it was addressed to. A key that names no issue resolves to `undefined`, a proven absence.\n\t */\n\tprotected override getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resourceId: string,\n\t\tid: string,\n\t\t_resourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\treturn this.readIssue(session, id, 'batch');\n\t}\n\n\t/**\n\t * Caches are keyed by the ADDRESS the read was made against as well as the token: one integration instance\n\t * exists per configured host and two hosts can hold the same token, so a token-only key would serve one\n\t * host's projects for the other — and the host alone is not enough either, because a connection re-pointed\n\t * to another context path on the same host keeps its token and would otherwise be served the old path's\n\t * projects.\n\t */\n\tprivate projectsCacheKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.apiBaseUrlFor(session)}:${session.accessToken}`;\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._projects.clear();\n\t\tthis._projectReads.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAC/E,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;AAuB3B,SAAS,iBAAiB,MAAsD;CAC/E,OAAO;EAAE,WAAW;EAAM,SAAS;CAAK;AACzC;AAmB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OAAO;CAC3C;;;;;;;;CASA,iBAAyB,SAAgD;EACxE,OAAO,GAAG,KAAK,cAAc,OAAO,EAAE,GAAG,QAAQ;CAClD;CAEA,uBAAgD;EAC/C,KAAK,UAAU,MAAM;EACrB,KAAK,cAAc,MAAM;EACzB,KAAK,WAAW,MAAM;EACtB,KAAK,iBAAiB,MAAM;CAC7B;CAEA,uBAAgD;EAC/C,KAAK,0BAA0B;CAChC;AACD"}
|
|
1
|
+
{"version":3,"file":"jira-server.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jira-server.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueProjection, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport { fnv1aHash64 } from '@gitlens/utils/hash.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { sessionExpiry, toTokenWithInfo } from '../authentication/models.js';\nimport { isIncompleteCollection, toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesSelfManagedHostIntegrationId } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport { groupProjectIssuesSearches, IssuesIntegration, toProjectsCollection } from '../models/issuesIntegration.js';\nimport type { IssueTrackerWriteConnection } from '../models/issueTrackerWrites.js';\nimport type { IntegrationKey } from '../models/publicIntegration.js';\nimport { areDomainsOnSameHost, baseUrlFromDomain } from '../utils/domain.utils.js';\nimport type { JiraIssueWriter } from './jiraIssueWrites.js';\nimport { providersMetadata } from './metadata.js';\nimport type { ProviderApiCollectionResult } from './models.js';\nimport { toAccount, toIssueShape, toProviderIssueStates } from './models.js';\nimport { isJiraServerMissingProjectError } from './providerErrors.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport { DiscoveryCache, discoveryCacheTtl } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\tsummarizePageMetadata,\n\ttoUniqueJiraIssueShapes,\n\twithFailureScope,\n} from './utils/jiraIssueDrains.js';\nimport { mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesSelfManagedHostIntegrationId.JiraServer];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n\n/**\n * Every clause is scoped by the HANDLE, and `options.userId` is deliberately ignored here — the one\n * place this provider diverges from Jira Cloud's, which applies it to `assignee`/`creator` (#5857).\n *\n * The two are not interchangeable because `Account.id` means something different per deployment. On\n * Cloud it is the `accountId`, which JQL resolves, so scoping by it fixes the deactivated-account case\n * where the display name no longer resolves. On Server it is the user KEY (`JIRAUSER10224`), which JQL\n * does not resolve at all: measured against a live Jira Server 8.20.13 site, `assignee in\n * (\"JIRAUSER10224\")` returns 0 with `\"The value 'JIRAUSER10224' does not exist for the field\n * 'assignee'\"` — the identical warning a genuinely nonexistent user produces — while the username and\n * the display name both return the real 4.\n *\n * So applying `userId` here would silently empty the read rather than harden it. Do not \"fix\" this\n * asymmetry to match Cloud without re-measuring against a Server instance.\n *\n * The handle itself is already the right one: `provider-apis` 0.60.0 maps `Account.username` from the\n * Server payload's `name` (falling back to `displayName` when absent), so these clauses are scoped by the\n * real username rather than a display name (GKDEV-3629). That is what makes the `mention` clause work at\n * all — it is a free-text `comment ~ \"...\"` over comment bodies, and a Jira mention is stored as\n * `[~username]`, which a display name never matches.\n */\nfunction toUserIdentities(user: string): { userField: string; mention: string } {\n\treturn { userField: user, mention: user };\n}\n\n/**\n * The single resource a Jira Server connection has: the instance itself.\n *\n * Jira Cloud's account spans many sites, so its resources come from an API call that lists them. A\n * self-hosted instance IS the one site the connection addresses, so there is nothing to enumerate — this\n * descriptor is synthesized from the configured host. Modelling it as a resource anyway keeps the\n * resource → project contract of {@link IssuesIntegration} intact, so every tracker read (`listOrgs`,\n * `listProjects`, `listIssueTrackerIssuesPage`) works unchanged.\n */\nexport interface JiraServerResourceDescriptor extends IssueResourceDescriptor {\n\turl: string;\n}\n\nexport interface JiraServerProjectDescriptor extends IssueResourceDescriptor {\n\tresourceId: string;\n}\n\nexport class JiraServerIntegration extends IssuesIntegration<IssuesSelfManagedHostIntegrationId.JiraServer> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = IssuesSelfManagedHostIntegrationId.JiraServer;\n\tprotected readonly key: IntegrationKey<IssuesSelfManagedHostIntegrationId.JiraServer>;\n\treadonly name: string = 'Jira Data Center';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t\tthis.key = `${this.id}:${this._domain}`;\n\t}\n\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\n\tprotected override getSessionFingerprint(session: ProviderAuthenticationSession): string {\n\t\treturn fnv1aHash64(JSON.stringify([this.apiBaseUrlFor(session), session.accessToken]));\n\t}\n\n\tasync getIssueWriter(\n\t\toptions: Extract<IssueTrackerWriteConnection, { providerId: IssuesSelfManagedHostIntegrationId.JiraServer }>,\n\t\tsession: ProviderAuthenticationSession,\n\t\tisSelectionCurrent: () => boolean,\n\t): Promise<{ writer: JiraIssueWriter; isCurrent: () => boolean }> {\n\t\tconst isSessionCurrent = this.authenticationService.trackStoredSession(this.id, session, true);\n\t\tconst isCurrent = () =>\n\t\t\tisSelectionCurrent() &&\n\t\t\tthis.isIntegrationAccessEnabled() &&\n\t\t\t!isSessionCurrent.isRetired() &&\n\t\t\tsessionExpiry(session.expiresAt) > Date.now();\n\t\tconst api = await this.getProvidersApi();\n\t\tconst writer = await api.getJiraServerIssueWriter(options, session, isCurrent, isSessionCurrent, () =>\n\t\t\tthis.getIgnoreSSLErrors(),\n\t\t);\n\t\treturn { writer: writer, isCurrent: isCurrent };\n\t}\n\n\t/**\n\t * The URL every request for this connection is addressed to, built from the SESSION's domain rather than\n\t * the integration's.\n\t *\n\t * `this.domain` is the host-keyed identity — `IntegrationService.get()` runs it through `hostFromDomain`\n\t * so one host can't build two instances — which means it has had any context path stripped, and so has\n\t * `session.domain`, which is stored as that same normalized host. Jira Data Center officially supports\n\t * being mounted below a context path (`https://jira.example.com/jira`), so the address comes from\n\t * {@link ProviderAuthenticationSession.baseUrl}, which carries the configured value verbatim; it falls\n\t * back to the host when the backend reported nothing more, which is the common case.\n\t *\n\t * Takes the session rather than reading `_session` so a per-connection (multi-account) read is addressed\n\t * to the host of the connection it resolved, not to whichever one happens to be current.\n\t */\n\tprotected apiBaseUrlFor(session: ProviderAuthenticationSession | undefined): string {\n\t\tconst configured = baseUrlFromDomain(session?.baseUrl, session?.protocol);\n\t\t// A `baseUrl` from another host is not this connection's address — refuse it rather than routing this\n\t\t// integration's reads somewhere its key never named.\n\t\tif (configured != null && areDomainsOnSameHost(session?.baseUrl, this.domain)) return configured;\n\n\t\treturn (\n\t\t\tbaseUrlFromDomain(session?.domain, session?.protocol) ??\n\t\t\tbaseUrlFromDomain(this.domain, session?.protocol) ??\n\t\t\t`${session?.protocol ?? 'https:'}//${this.domain}`\n\t\t);\n\t}\n\n\t/** The one resource this connection has — see {@link JiraServerResourceDescriptor}. */\n\tprivate resourceFor(session: ProviderAuthenticationSession | undefined): JiraServerResourceDescriptor {\n\t\treturn { id: this.domain, key: this.domain, name: this.domain, url: this.apiBaseUrlFor(session) };\n\t}\n\n\tprivate readonly _autolinks = new Map<string, { autolinks: AutolinkReference[]; builtAt: number }>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<AutolinkReference[]>>();\n\n\toverride async autolinks(): Promise<AutolinkReference[]> {\n\t\tconst generation = this.discoveryGeneration;\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) return [];\n\t\tif (!this.isResolvedSessionCurrent(this._session, generation)) return [];\n\n\t\tconst session = this._session;\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tconst cached = this._autolinks.get(cacheKey);\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (Date.now() - cached.builtAt >= discoveryCacheTtl) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\tprivate buildAutolinks(session: ProviderAuthenticationSession): Promise<AutolinkReference[]> {\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tlet build = this._autolinksBuilds.get(cacheKey);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session).finally(() => {\n\t\t\t\tif (this._autolinksBuilds.get(cacheKey) === build) {\n\t\t\t\t\tthis._autolinksBuilds.delete(cacheKey);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._autolinksBuilds.set(cacheKey, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(session: ProviderAuthenticationSession): Promise<AutolinkReference[]> {\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tconst generation = this._projects.generation;\n\t\ttry {\n\t\t\tconst resource = this.resourceFor(session);\n\t\t\tconst result = await this.getProjectsForResourcesWithMetadataResult([resource]);\n\t\t\tif (this._projects.generation !== generation) return [];\n\t\t\tif (result?.value == null || result.error != null || isIncompleteCollection(result.value.metadata)) {\n\t\t\t\treturn this._autolinks.get(cacheKey)?.autolinks ?? [];\n\t\t\t}\n\n\t\t\tconst autolinks: AutolinkReference[] = [];\n\t\t\tfor (const project of result.value.values) {\n\t\t\t\tif (project.key === project.id) continue;\n\n\t\t\t\tautolinks.push(\n\t\t\t\t\t...createIssueAutolinkReferences(\n\t\t\t\t\t\tproject.key,\n\t\t\t\t\t\t`${resource.url}/browse/${project.key}-<num>`,\n\t\t\t\t\t\tresource,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis._autolinks.set(cacheKey, { autolinks: autolinks, builtAt: Date.now() });\n\t\t\treturn autolinks;\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, 'JiraServerIntegration.autolinks');\n\t\t\treturn this._autolinks.get(cacheKey)?.autolinks ?? [];\n\t\t}\n\t}\n\n\tprotected override getProviderCurrentAccount(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\treturn this.getProviderAccountForResource(session, this.resourceFor(session));\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: JiraServerResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getJiraServerCurrentUser(toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session));\n\n\t\tif (user == null) return undefined;\n\t\treturn toAccount(user, this);\n\t}\n\n\tprotected override getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_force?: boolean,\n\t): Promise<JiraServerResourceDescriptor[] | undefined> {\n\t\t// Synthesized from the configured host rather than fetched, so there is nothing to cache or force.\n\t\treturn Promise.resolve([this.resourceFor(session)]);\n\t}\n\n\t/** Expires, and is dropped on a re-sync, so a project created or deleted mid-session is picked up (#5907). */\n\tprivate readonly _projects = new DiscoveryCache<JiraServerProjectDescriptor[]>();\n\tprivate readonly _projectReads = new Map<string, Promise<JiraServerProjectDescriptor[] | undefined>>();\n\tprotected override getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraServerResourceDescriptor[],\n\t): Promise<JiraServerProjectDescriptor[] | undefined> {\n\t\t// Every resource here is this instance (see `getProviderResourcesForUser`), so one read serves them\n\t\t// all; a caller that passes none is asking for nothing.\n\t\tif (resources.length === 0) return Promise.resolve([]);\n\n\t\tconst cacheKey = this.projectsCacheKey(session);\n\t\tconst cached = this._projects.get(cacheKey);\n\t\tif (cached != null) return Promise.resolve(cached);\n\n\t\tlet read = this._projectReads.get(cacheKey);\n\t\tif (read == null) {\n\t\t\tread = this.readProjectsCached(session, cacheKey).finally(() => {\n\t\t\t\tif (this._projectReads.get(cacheKey) === read) {\n\t\t\t\t\tthis._projectReads.delete(cacheKey);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._projectReads.set(cacheKey, read);\n\t\t}\n\t\treturn read;\n\t}\n\n\tprivate async readProjectsCached(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcacheKey: string,\n\t): Promise<JiraServerProjectDescriptor[] | undefined> {\n\t\tconst generation = this._projects.generation;\n\t\tconst descriptors = await this.readProjects(session);\n\t\tif (descriptors == null) return undefined;\n\n\t\tif (this._projects.set(cacheKey, descriptors, { generation: generation }) !== false) {\n\t\t\tthis._autolinks.delete(cacheKey);\n\t\t}\n\n\t\treturn descriptors;\n\t}\n\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraServerResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<JiraServerProjectDescriptor>> {\n\t\tif (resources.length === 0) return { values: [] };\n\n\t\treturn toProjectsCollection(await this.readProjects(session));\n\t}\n\n\tprivate async readProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraServerProjectDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst projects = await api.getJiraServerProjects(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t\tif (projects == null) return undefined;\n\t\tif (projects.length === 0) {\n\t\t\t// Jira can serve anonymous empty projects after rejection without an identifying response header.\n\t\t\tconst account = await this.getProviderAccountForResource(session, this.resourceFor(session));\n\t\t\tif ((account?.username ?? account?.name) == null) return undefined;\n\t\t}\n\n\t\tconst resourceId = this.resourceFor(session).id;\n\t\treturn projects.map<JiraServerProjectDescriptor>(p => ({\n\t\t\tid: p.id,\n\t\t\t// The project key, which selects the project (`listProjects`' `name`) and is what an issue key starts\n\t\t\t// with. The SDK does not validate it, so a missing or blank one falls back to the numeric id, never to the\n\t\t\t// display name, which can equal another project's key. The reads below still address the project by\n\t\t\t// `id`, which no other project can share.\n\t\t\tkey: p.key?.trim() || p.id,\n\t\t\tname: p.name,\n\t\t\tresourceId: resourceId,\n\t\t}));\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraServerProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraServerProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\n\t\t// The same drain as Jira Cloud's (`jiraIssueDrains.ts`): page to a defensive backstop, and report `truncated`\n\t\t// plus a structured failure rather than discarding an already-fetched prefix.\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\t// The numeric project id, not the name: JQL resolves `project = \"<value>\"` against key first, so a display\n\t\t// name that matches another project's key reads that project's issues instead. A Jira project key must begin\n\t\t// with a letter, so a purely numeric value can only be an id.\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getJiraServerIssuesForProjectPaged(tokenWithInfo, baseUrl, project.id, {\n\t\t\t\t...scope,\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t\tsort: options?.sort,\n\t\t\t});\n\t\tconst drainOptions: JiraDrainOptions = {\n\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\t// Scoped by key, as on Jira Cloud: the id addresses the read, the key is how a consumer names the project.\n\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId, projectId: project.key },\n\t\t\tproviderName: 'Jira Server',\n\t\t\t// A project this connection can no longer see (deleted, or its browse permission removed) holds\n\t\t\t// no issues for it, and the project list that named it is stale: drop that list so the next read\n\t\t\t// re-reads it, instead of failing the whole provider on every read until a restart (#5907).\n\t\t\tisEmptyFailure: ex => {\n\t\t\t\tif (!isJiraServerMissingProjectError(ex)) return false;\n\n\t\t\t\tLogger.warn(`Jira Server project '${project.name}' (${project.id}) no longer exists or is not visible`);\n\t\t\t\tthis.invalidateDiscoveryCaches();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\n\t\tif (options?.user != null) {\n\t\t\tconst read = await readUserScopedJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\toptions.filters,\n\t\t\t\ttoUserIdentities(options.user),\n\t\t\t\tdrainOptions,\n\t\t\t);\n\t\t\tconst values = toUniqueJiraIssueShapes(read.issues, this);\n\t\t\tconst drain = { values: values, metadata: read.metadata, scope: drainOptions.failureScope };\n\t\t\t// `recovery: 'none'` for the whole set: the filter branches merge here, so even a pure backstop in one\n\t\t\t// branch is not fixable by narrowing this read's scope.\n\t\t\treturn read.truncated ? { ...drain, truncated: true, recovery: 'none' } : { ...drain, truncated: false };\n\t\t}\n\n\t\tconst unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);\n\t\tconst values = unscoped.issues\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'project' }))\n\t\t\t.filter((result): result is IssueShape => result !== undefined);\n\t\tconst drain = { values: values, metadata: unscoped.metadata, scope: drainOptions.failureScope };\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? { ...drain, truncated: true, recovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none' }\n\t\t\t: { ...drain, truncated: false };\n\t}\n\n\t/**\n\t * Searches the instance's projects together for a user-scoped read, as Jira Cloud does per site: one JQL names\n\t * up to {@link JIRA_MAX_PROJECT_KEYS_PER_REQUEST} projects of one user scope. An unscoped read stays per project,\n\t * since its backstop is reported as `narrow-scope` per project.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<JiraServerProjectDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(\n\t\t\trequests,\n\t\t\t({ options }) =>\n\t\t\t\toptions.user != null\n\t\t\t\t\t? [options.user, options.sort ?? '', options.state ?? '', options.filters?.join(',') ?? ''].join(\n\t\t\t\t\t\t\t'\\0',\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined,\n\t\t\tJIRA_MAX_PROJECT_KEYS_PER_REQUEST,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<JiraServerProjectDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares its user scope (see `getProjectIssuesSearches`).\n\t\tconst { options } = requests[0];\n\t\tif (options.user == null) return undefined;\n\t\t// One project's search is its own read, by the same numeric id, so it costs no more to read it as one. And it\n\t\t// reports what the search can't: a dropped issue's failure, which a search can only answer by being read again.\n\t\tif (requests.length === 1) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\t// By numeric id, as the per-project read names them (see there).\n\t\tconst projectIds = requests.map(request => request.project.id);\n\t\tconst states = toProviderIssueStates(options.state);\n\n\t\treturn searchJiraProjectIssues(\n\t\t\t(userScope, cursor) =>\n\t\t\t\tapi.getJiraServerIssuesForProjectsPaged(tokenWithInfo, baseUrl, projectIds, {\n\t\t\t\t\t...userScope,\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tstates: states,\n\t\t\t\t\tsort: options.sort,\n\t\t\t\t}),\n\t\t\tprojectIds,\n\t\t\toptions.filters,\n\t\t\ttoUserIdentities(options.user),\n\t\t\t{ maxPages: maxPagesPerRequest, failureScope: { providerId: this.id }, providerName: 'Jira Server' },\n\t\t\tthis,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraServerResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * Account-wide \"my issues\" for this instance, drained to the backstop and reporting whether it got there.\n\t *\n\t * The override exists for the same reason the project drain reports `status`: the default\n\t * implementation wraps whatever the normalized read returned as `truncated: false`, so a run that stopped\n\t * at `maxPagesPerRequest` with pages left, or on a continuation the server never advanced, would be\n\t * published as a complete account. Cancellation is NOT truncation — the caller asked for the stop and\n\t * already knows the prefix is partial — so it breaks without setting the flag.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources?: JiraServerResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\n\t\t// Errors propagate, unlike Jira Cloud's sibling. Cloud swallows per resource because it loops over the\n\t\t// account's many sites and one bad site must not discard the others; this connection addresses exactly\n\t\t// one instance, so there is no sibling to protect and swallowing would turn every failure — an expired\n\t\t// token, an unreachable host — into an empty success. `searchMyIssuesWithTruncationResult` recovers the\n\t\t// throw into `{ error }`, which is what lets the caller warn instead of reporting \"no issues\".\n\t\t// Only the provider: the instance is this connection's single resource, so naming it would publish a\n\t\t// failure of the whole connection as one confined to a sub-scope (see `ProviderWarning.scope`).\n\t\tconst accountScope = { providerId: this.id };\n\t\tconst results: IssueShape[] = [];\n\t\tlet cursor: string | undefined;\n\t\tlet truncated = false;\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tconst pages: CollectionMetadata[] = [];\n\n\t\tconst stopIncomplete = (reason: string) => {\n\t\t\ttruncated = true;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\tcompleteness: 'partial',\n\t\t\t\tfailures: [toCollectionScopeFailure(accountScope, new Error(reason))],\n\t\t\t});\n\t\t};\n\n\t\tfor (let i = 0; i < maxPagesPerRequest; i++) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst page = await api.getJiraServerIssuesForCurrentUser(tokenWithInfo, baseUrl, {\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t});\n\t\t\tif (page == null) {\n\t\t\t\t// Nothing fetched yet and no page is an empty account, not a failure; after a continuation it\n\t\t\t\t// means the server dropped the drain mid-way.\n\t\t\t\tif (cursor != null) {\n\t\t\t\t\tstopIncomplete('Jira Server returned no page after advertising a continuation');\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tresults.push(\n\t\t\t\t...page.data\n\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t.filter((r): r is IssueShape => r != null),\n\t\t\t);\n\t\t\t// An issue the page dropped because it could not be read arrives here, not as a missing row; recorded under\n\t\t\t// the same scope as this read's other failures.\n\t\t\tif (page.metadata != null) {\n\t\t\t\t// Truncated too, as Jira Cloud's read is through `getPagedResult`: the account is missing that issue.\n\t\t\t\ttruncated ||= isIncompleteCollection(page.metadata);\n\t\t\t\tpages.push(withFailureScope(page.metadata, accountScope));\n\t\t\t}\n\n\t\t\tif (!page.hasMore) break;\n\n\t\t\t// More pages are claimed but no advancing cursor came back: the drain can't continue, so flag it\n\t\t\t// rather than stopping silently.\n\t\t\tif (page.nextCursor == null || page.nextCursor === cursor) {\n\t\t\t\tstopIncomplete('Jira Server returned no advancing issue continuation');\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcursor = page.nextCursor;\n\t\t\t// Pages remain but this was the last allowed iteration: the backstop stopped the drain.\n\t\t\tif (i === maxPagesPerRequest - 1) {\n\t\t\t\tstopIncomplete(\n\t\t\t\t\t`Jira Server account-wide issue drain stopped at the ${maxPagesPerRequest}-page backstop`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: results,\n\t\t\ttruncated: truncated,\n\t\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t\t};\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: JiraServerResourceDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getJiraServerIssue(toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session), key);\n\t\treturn issue != null ? toIssueShape(issue, this, { projection: 'point' }) : undefined;\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: JiraServerResourceDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\treturn this.readIssue(session, id, 'point');\n\t}\n\n\tprivate async readIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tid: string,\n\t\tprojection: IssueProjection,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getJiraServerIssue(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tid,\n\t\t);\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: projection }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\t/**\n\t * The point read behind `getIssuesBatch`'s tracker targets (#5872). `resourceId` is this connection's single\n\t * synthetic resource — the host itself, see {@link JiraServerResourceDescriptor} — so it selects nothing further\n\t * here: the host was chosen upstream by `domain` (or the connection's configured domain) and the request is\n\t * addressed to the SESSION's base URL like every other read. No `resourceUrl` is needed either, unlike Jira\n\t * Cloud: its REST `self` link is an API endpoint, whereas `getJiraServerIssue` builds the browser link from\n\t * the base URL it was addressed to. A key that names no issue resolves to `undefined`, a proven absence.\n\t */\n\tprotected override getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resourceId: string,\n\t\tid: string,\n\t\t_resourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\treturn this.readIssue(session, id, 'batch');\n\t}\n\n\t/**\n\t * Caches are keyed by the ADDRESS the read was made against as well as the token: one integration instance\n\t * exists per configured host and two hosts can hold the same token, so a token-only key would serve one\n\t * host's projects for the other — and the host alone is not enough either, because a connection re-pointed\n\t * to another context path on the same host keeps its token and would otherwise be served the old path's\n\t * projects.\n\t */\n\tprivate projectsCacheKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.apiBaseUrlFor(session)}:${session.accessToken}`;\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._projects.clear();\n\t\tthis._projectReads.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgDA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAC/E,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;AAuB3B,SAAS,iBAAiB,MAAsD;CAC/E,OAAO;EAAE,WAAW;EAAM,SAAS;CAAK;AACzC;AAmBA,IAAa,wBAAb,cAA2C,kBAAiE;CAWzF;CAVlB,eAAqE;CACrE,KAAS;CACT;CACA,OAAwB;CAExB,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;EAGjB,KAAK,MAAM,GAAG,KAAK,GAAG,GAAG,KAAK;CAC/B;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CAEA,sBAAyC,SAAgD;EACxF,OAAO,YAAY,KAAK,UAAU,CAAC,KAAK,cAAc,OAAO,GAAG,QAAQ,WAAW,CAAC,CAAC;CACtF;CAEA,MAAM,eACL,SACA,SACA,oBACiE;EACjE,MAAM,mBAAmB,KAAK,sBAAsB,mBAAmB,KAAK,IAAI,SAAS,IAAI;EAC7F,MAAM,kBACL,mBAAmB,KACnB,KAAK,2BAA2B,KAChC,CAAC,iBAAiB,UAAU,KAC5B,cAAc,QAAQ,SAAS,IAAI,KAAK,IAAI;EAK7C,OAAO;GAAE,QAAQ,OAHI,MADH,KAAK,gBAAgB,EAAA,CACd,yBAAyB,SAAS,SAAS,WAAW,wBAC9E,KAAK,mBAAmB,CACzB;GACoC;EAAU;CAC/C;;;;;;;;;;;;;;;CAgBA,cAAwB,SAA4D;EACnF,MAAM,aAAa,kBAAkB,SAAS,SAAS,SAAS,QAAQ;E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3 +1,5 @@
|
|
|
1
|
+
import { ProviderAuthenticationSession } from "../authentication/models.js";
|
|
2
|
+
import { IssuesSelfManagedHostIntegrationId } from "../constants.js";
|
|
1
3
|
import { IssueTrackerCreateOptions, IssueTrackerCreateOptionsResult, IssueTrackerDeleteOptions, IssueTrackerIssueWriteOptions, IssueTrackerIssueWriteOptionsResult, IssueTrackerWriteConnection, IssueTrackerWriteOptions, IssueTrackerWriteResult, IssueTrackerWriteTargetOptions, IssueTrackerWriteTargetResult } from "../models/issueTrackerWrites.js";
|
|
2
4
|
import { ProviderRequestFunction } from "./models.js";
|
|
3
5
|
//#region ../plus/integrations/src/providers/jiraIssueWrites.d.ts
|
|
@@ -8,6 +10,9 @@ export declare class JiraIssueWriter {
|
|
|
8
10
|
private readonly site;
|
|
9
11
|
private readonly isSessionCurrent;
|
|
10
12
|
static connect(request: ProviderRequestFunction, accessToken: string, options: IssueTrackerWriteConnection, isSessionCurrent: () => Promise<boolean>): Promise<JiraIssueWriter>;
|
|
13
|
+
static connectServer(request: ProviderRequestFunction, session: ProviderAuthenticationSession, options: Extract<IssueTrackerWriteConnection, {
|
|
14
|
+
providerId: IssuesSelfManagedHostIntegrationId.JiraServer;
|
|
15
|
+
}>, isSessionCurrent: () => Promise<boolean>): Promise<JiraIssueWriter>;
|
|
11
16
|
private accountId;
|
|
12
17
|
private constructor();
|
|
13
18
|
getCreateOptions(options: IssueTrackerCreateOptions): Promise<IssueTrackerCreateOptionsResult>;
|
|
@@ -18,6 +23,7 @@ export declare class JiraIssueWriter {
|
|
|
18
23
|
private createIssue;
|
|
19
24
|
private updateIssue;
|
|
20
25
|
private editableFields;
|
|
26
|
+
private resolveMutationIssue;
|
|
21
27
|
private resolveIssue;
|
|
22
28
|
private readIssue;
|
|
23
29
|
private readCreateProject;
|