@gitkraken/core-gitlens 0.60.0 → 0.61.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.
@@ -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 {\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;A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J,IAAI,UAAU,YAAY,cAAc,QAAQ,aAAa,cAAc,QAAQ,WAClF,SAAS;IAEV;GACD,KAAK;IACJ,KACE,QAAQ,UAAU,KAAA,KAAa,SAAS,UAAU,QAAQ,WAC1D,QAAQ,gBAAgB,KAAA,KAAa,SAAS,gBAAgB,QAAQ,cAEvE,SAAS;IAEV;GACD,KAAK;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"}
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 {\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') return 'conflict';\n\tif (raw.mergeStatus === 'queued') return 'unknown';\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,IAAI,SAAS,IAAI,KAClB,CAAC,IAAI,SAAS,GAAG,KACjB,IAAI,MAAM,GAAG,CAAC,CAAC,OAAM,SAAQ,KAAK,SAAS,KAAK,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,SAAS,OAAO,CAAC;AAElG;AAEA,SAAgB,wBACf,SACU;CACV,IAAI,QAAQ,eAAe,uBAC1B,OAAO,qBAAqB,OAAO,KAAK,cAAc,QAAQ,UAAU;CAGzE,QACE,QAAQ,eAAe,KAAA,KAAa,QAAQ,eAAe,kBAC5D,kBAAkB,QAAQ,YAAY,KACtC,OAAO,QAAQ,iBAAiB,YAChC,wBAAwB,KAAK,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QAAQ;EAAkB,IACvC;GAAE,IAAI;GAAc;GAAQ,aAAa;IAAE,GAAG;IAAiB;GAAM;EAAE;CAC3E;AACD"}
@@ -1208,8 +1208,9 @@ the live source tip and sends Azure the approved SHA in `lastMergeSourceCommit`.
1208
1208
 
1209
1209
  Before dispatch Core checks the strategy and live refs, rereads the PR for retargeting, and checks the
1210
1210
  approved target tip again. A conflict from the current preview blocks completion. If the preview targets
1211
- an older tip, Azure evaluates the current merge on dispatch. A queued merge remains unavailable for
1212
- completion. Azure's update API provides no atomic target or PR revision comparison, so the target may
1211
+ an older tip, Azure evaluates the current merge on dispatch. When Azure reports the PR as active with
1212
+ a queued merge evaluation, completion is unavailable with reason `unknown` before dispatch.
1213
+ Azure's update API provides no atomic target or PR revision comparison, so the target may
1213
1214
  move after the preflight reads.
1214
1215
  Completion explicitly requests the selected merge strategy with policy bypass disabled.
1215
1216
  See the [Azure DevOps update API](https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/update?view=azure-devops-rest-7.1)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.60.0",
4
+ "version": "0.61.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",