@gitkraken/core-gitlens 0.53.0 → 0.55.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 +20 -1
- package/dist/git/models/pullRequest.d.ts +14 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -1
- package/dist/git/utils/pullRequest.utils.js +9 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +2 -0
- package/dist/plus/git-github/api/github.js +16 -6
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.d.ts +1 -0
- package/dist/plus/git-github/api/pullRequestSearchQuery.js +29 -5
- package/dist/plus/git-github/api/pullRequestSearchQuery.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +3 -0
- package/dist/plus/integrations/fieldPresence.js +7 -1
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +4 -4
- package/dist/plus/integrations/index.js +1 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +8 -7
- package/dist/plus/integrations/integrationService.js +11 -9
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +12 -7
- package/dist/plus/integrations/models/azurePullRequestWrites.d.ts +31 -8
- package/dist/plus/integrations/models/publicIntegration.d.ts +1 -0
- package/dist/plus/integrations/models/pullRequestReads.d.ts +2 -0
- package/dist/plus/integrations/providers/azure/writeIdentity.d.ts +9 -0
- package/dist/plus/integrations/providers/azure/writeIdentity.js +19 -1
- package/dist/plus/integrations/providers/azure/writeIdentity.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +1 -1
- package/dist/plus/integrations/providers/azureDevOps.js +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +4 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js +21 -8
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/azurePullRequestWrites.d.ts +12 -4
- package/dist/plus/integrations/providers/azurePullRequestWrites.js +55 -11
- package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +6 -15
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/metadata.js +6 -3
- package/dist/plus/integrations/providers/metadata.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +16 -6
- package/dist/plus/integrations/providers/providersApi.js +43 -14
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/filters.js +13 -1
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +3 -3
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/resolveRepository.js +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +3 -3
- package/dist/plus/integrations/reads/searchPullRequests.js +4 -3
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +20 -6
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +1 -0
- package/dist/plus/integrations/reads/warnings.js +7 -2
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +7 -0
- package/dist/plus/integrations/results.js.map +1 -1
- package/docs/integrations.md +102 -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\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\tisAzureIdentifier,\n\tisAzurePositiveInt,\n\tsameAzureIdentifier,\n} from './azure/writeIdentity.js';\nimport { AzurePullRequestWriteError, toAzurePullRequestWriteFailure } from './azurePullRequestWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.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 CompletionOptions = Extract<AzurePullRequestWriteOptions, { 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 isAzureIdentifier(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\nfunction isCommitId(sha: unknown): sha is string {\n\treturn typeof sha === 'string' && /^(?!0{40}$)[0-9a-f]{40}$/i.test(sha);\n}\n\nexport function isAzurePullRequestScope(options: AzurePullRequestCreateCapabilityOptions): boolean {\n\treturn (\n\t\tisAzureIdentifier(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 || isAzureIdentifier(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: AzurePullRequestWriteOptions): boolean {\n\tif (\n\t\t!isAzureGuid(options.projectId) ||\n\t\t!isAzureGuid(options.repositoryId) ||\n\t\t!isAzureIdentifier(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 (!isAzurePositiveInt(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\tisCommitId(options.expectedSourceSha) &&\n\t\t\t\tisCommitId(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!sameAzureIdentifier(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 (!isCommitId(previewTargetSha)) return 'unknown';\n\tif (!sameAzureIdentifier(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!isAzureIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameAzureIdentifier(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\tsameAzureIdentifier(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!sameAzureIdentifier(isAzureGuid(options.repository) ? repo.id : repo.name, options.repository) ||\n\t\t\t!sameAzureIdentifier(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\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) {\n\t\tthis.gitApiUrl = `${azureBaseUrl}/${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 (!isAzurePositiveInt(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: AzurePullRequestWriteOptions): 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\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 (!sameAzureIdentifier(source, options.expectedSourceSha)) return { ok: false, reason: 'source-changed' };\n\t\tif (!sameAzureIdentifier(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 (!sameAzureIdentifier(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: { 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 (!sameAzureIdentifier(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 async getAllowedStrategies(ref: string): Promise<AzurePullRequestMergeStrategy[]> {\n\t\tconst query = new URLSearchParams({\n\t\t\t'api-version': '7.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 = mergeStrategies.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': '7.1', 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 isCommitId(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=7.1`;\n\t}\n\n\tprivate toPullRequestSnapshot(raw: AzurePullRequest, number?: number): PullRequestSnapshot {\n\t\tif (\n\t\t\t!sameAzureIdentifier(raw?.repository?.id, this.repository.repositoryId) ||\n\t\t\t!sameAzureIdentifier(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!isAzurePositiveInt(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\tazureBaseUrl,\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: isCommitId(sourceSha) ? sourceSha : undefined,\n\t\t\ttargetSha: isCommitId(targetSha) ? targetSha : undefined,\n\t\t};\n\t}\n\n\tprivate async save(options: AzurePullRequestWriteOptions, 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: AzurePullRequestWriteOptions,\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":";;;;AAwBA,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;AAiB5G,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,KACl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AAK,WAAW,SAAS,KAAK,QAAQ;CAC9C;CAEA,WACC,SACA,KACA,UAC8B;EAC9B,MAAM,EAAE,OAAO,WAAW,cAAc;EACxC,IAAI;EACJ,QAAQ,QAAQ,QAAhB;GACC,KAAK;IACJ,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,IAAI,WAAW;IACvD,IAAI,WAAW,MAAM,OAAO;KAAE,IAAI;KAAO,QAAQ;IAAQ;IAEzD,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\tisAzureIdentifier,\n\tisAzurePositiveInt,\n\tsameAzureIdentifier,\n\tverifyAzureServerCollection,\n} from './azure/writeIdentity.js';\nimport { AzurePullRequestWriteError, toAzurePullRequestWriteFailure } from './azurePullRequestWriteErrors.js';\nimport { isWorkItemWriteScope } from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.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 isAzureIdentifier(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\nfunction isCommitId(sha: unknown): sha is string {\n\treturn typeof sha === 'string' && /^(?!0{40}$)[0-9a-f]{40}$/i.test(sha);\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\tisAzureIdentifier(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 || isAzureIdentifier(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!isAzureIdentifier(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 (!isAzurePositiveInt(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\tisCommitId(options.expectedSourceSha) &&\n\t\t\t\tisCommitId(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!sameAzureIdentifier(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 (!isCommitId(previewTargetSha)) return 'unknown';\n\tif (!sameAzureIdentifier(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!isAzureIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameAzureIdentifier(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\tsameAzureIdentifier(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!sameAzureIdentifier(isAzureGuid(options.repository) ? repo.id : repo.name, options.repository) ||\n\t\t\t!sameAzureIdentifier(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!sameAzureIdentifier(repo.project?.id, options.projectId) ||\n\t\t\t!sameAzureIdentifier(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 (!isAzurePositiveInt(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 (!sameAzureIdentifier(source, options.expectedSourceSha)) return { ok: false, reason: 'source-changed' };\n\t\tif (!sameAzureIdentifier(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 (!sameAzureIdentifier(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 (!sameAzureIdentifier(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 isCommitId(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!sameAzureIdentifier(raw?.repository?.id, this.repository.repositoryId) ||\n\t\t\t!sameAzureIdentifier(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!isAzurePositiveInt(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: isCommitId(sourceSha) ? sourceSha : undefined,\n\t\t\ttargetSha: isCommitId(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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,QAAQ,QAAhB;GACC,KAAK;IACJ,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,IAAI,WAAW;IACvD,IAAI,WAAW,MAAM,OAAO;KAAE,IAAI;KAAO,QAAQ;IAAQ;IAEzD,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,7 +1,6 @@
|
|
|
1
1
|
import { encodeAzurePathSegment } from "./azure/models.js";
|
|
2
|
-
import { getAzureWriteOrganizations, getAzureWriteProfile, isAzureGuid, isAzureIdentifier, isAzurePositiveInt, sameAzureIdentifier } from "./azure/writeIdentity.js";
|
|
2
|
+
import { getAzureWriteOrganizations, getAzureWriteProfile, isAzureGuid, isAzureIdentifier, isAzurePositiveInt, sameAzureIdentifier, verifyAzureServerCollection } from "./azure/writeIdentity.js";
|
|
3
3
|
import { WorkItemWriteError, WorkItemWriteNotDispatchedError, toWorkItemWriteFailure } from "./azureWorkItemWriteErrors.js";
|
|
4
|
-
import { decodeAzurePathSegment } from "./azure/azure.utils.js";
|
|
5
4
|
import { getAzureWorkItemBodyField, getAzureWorkItemTransitionTargets, isAzureProjectPathField, isAzureTestArtifact, toAzureWorkItemWriteFields } from "./azure/workItemWriteMetadata.js";
|
|
6
5
|
//#region ../plus/integrations/src/providers/azureWorkItemWrites.ts
|
|
7
6
|
const projectSecurityNamespaceId = "52d39943-cb85-4d7f-8fa8-c6baac873819";
|
|
@@ -132,16 +131,8 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
132
131
|
}
|
|
133
132
|
static async connectServer(request, authorization, options, collectionUrl, resolveApiVersion, resolveStatesApiVersion, isSessionCurrent) {
|
|
134
133
|
const headers = { Authorization: authorization };
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
headers,
|
|
138
|
-
redirect: "error"
|
|
139
|
-
});
|
|
140
|
-
const accountId = data?.authenticatedUser?.id;
|
|
141
|
-
const segment = typeof data?.webApplicationRelativeDirectory === "string" ? data.webApplicationRelativeDirectory.split("/").findLast(Boolean) : void 0;
|
|
142
|
-
const collectionName = segment != null ? decodeAzurePathSegment(segment) : void 0;
|
|
143
|
-
if (!isAzureGuid(data?.instanceId) || !sameAzureIdentifier(data.instanceId, options.organizationId) || collectionName == null || !sameAzureIdentifier(collectionName, options.organizationName)) throw new WorkItemWriteError("not-found");
|
|
144
|
-
if (!isAzureIdentifier(accountId) || options.expectedAccountId !== void 0 && !sameAzureIdentifier(accountId, options.expectedAccountId)) throw new WorkItemWriteError("no-connection");
|
|
134
|
+
const collection = await verifyAzureServerCollection(request, headers, collectionUrl, options);
|
|
135
|
+
if (typeof collection === "string") throw new WorkItemWriteError(collection);
|
|
145
136
|
const apiVersion = await resolveApiVersion();
|
|
146
137
|
if (apiVersion == null) throw new WorkItemWriteError("unsupported");
|
|
147
138
|
const project = await readProject(request, headers, collectionUrl, options.projectId, apiVersion);
|
|
@@ -150,10 +141,10 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
150
141
|
providerId: options.providerId,
|
|
151
142
|
connectionId: options.connectionId,
|
|
152
143
|
baseUrl: options.baseUrl,
|
|
153
|
-
accountId,
|
|
144
|
+
accountId: collection.accountId,
|
|
154
145
|
organization: {
|
|
155
|
-
id:
|
|
156
|
-
name:
|
|
146
|
+
id: collection.id,
|
|
147
|
+
name: collection.name,
|
|
157
148
|
url: collectionUrl
|
|
158
149
|
},
|
|
159
150
|
project
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureWorkItemWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWrites.ts"],"sourcesContent":["import type {\n\tAzureServerWorkItemWriteScope,\n\tAzureServicesWorkItemWriteScope,\n\tWorkItemAddress,\n\tWorkItemCreateOptions,\n\tWorkItemCreateOptionsResult,\n\tWorkItemDeleteCapability,\n\tWorkItemDeleteOptions,\n\tWorkItemDeleteResult,\n\tWorkItemReceipt,\n\tWorkItemState,\n\tWorkItemWriteContext,\n\tWorkItemWriteField,\n\tWorkItemWriteOptions,\n\tWorkItemWriteOptionsResult,\n\tWorkItemWriteResult,\n\tWorkItemWriteTargetOptions,\n\tWorkItemWriteTargetResult,\n} from '../models/workItemWrites.js';\nimport { decodeAzurePathSegment } from './azure/azure.utils.js';\nimport { encodeAzurePathSegment } from './azure/models.js';\nimport type {\n\tAzureWorkItemFieldDefinition,\n\tAzureWorkItemTypeCategory,\n\tAzureWorkItemTypeField,\n\tAzureWorkItemTypeMetadata,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWorkItemBodyField,\n\tgetAzureWorkItemTransitionTargets,\n\tisAzureProjectPathField,\n\tisAzureTestArtifact,\n\ttoAzureWorkItemWriteFields,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tisAzureIdentifier,\n\tisAzurePositiveInt,\n\tsameAzureIdentifier,\n} from './azure/writeIdentity.js';\nimport {\n\ttoWorkItemWriteFailure,\n\tWorkItemWriteError,\n\tWorkItemWriteNotDispatchedError,\n} from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.js';\n\ntype AzureWorkItem = { id: number; rev: number; fields: Readonly<Record<string, unknown>> };\ntype AzureDeletedWorkItem = {\n\tid?: unknown;\n\tproject?: unknown;\n\tdeletedDate?: unknown;\n\tcode?: unknown;\n\tresource?: { id?: unknown; rev?: unknown };\n};\ntype WorkItemMetadata = {\n\ttype: AzureWorkItemTypeMetadata;\n\tstates: readonly WorkItemState[];\n\tfields: readonly WorkItemWriteField[];\n\tcatalog: readonly AzureWorkItemFieldDefinition[];\n};\ntype Patch = { op: 'add' | 'test'; path: string; value: unknown } | { op: 'remove'; path: string };\n\ntype AzureServerConnectionData = {\n\tinstanceId?: unknown;\n\twebApplicationRelativeDirectory?: unknown;\n\tauthenticatedUser?: { id?: unknown };\n};\n\nconst projectSecurityNamespaceId = '52d39943-cb85-4d7f-8fa8-c6baac873819';\n\nfunction isSameId(actual: unknown, id: number): boolean {\n\treturn actual === id || actual === String(id);\n}\n\nfunction isDeletedItem(\n\titem: AzureDeletedWorkItem | undefined,\n\tid: number,\n): item is AzureDeletedWorkItem & { project: string } {\n\tif (item == null || !isSameId(item.id, id) || !isAzureIdentifier(item.project)) return false;\n\n\treturn (\n\t\titem.code == null || item.code === 0 || (typeof item.code === 'number' && item.code >= 200 && item.code < 300)\n\t);\n}\n\nfunction getDeletedRevision(item: AzureDeletedWorkItem, id: number): number | undefined {\n\tconst resource = item.resource;\n\treturn resource != null && isSameId(resource.id, id) && isAzurePositiveInt(resource.rev) ? resource.rev : undefined;\n}\n\n// SEE: Azure reports `deletedDate` as a zone-less en-US UTC string (\"11/25/2026 6:24:35 PM\"), observed live.\nconst azureDeletedDate = /^(\\d{1,2})\\/(\\d{1,2})\\/([12]\\d{3}) (\\d{1,2}):([0-5]\\d):([0-5]\\d) (AM|PM)$/;\n\nfunction toDeletedAt(value: unknown): string | undefined {\n\tconst match = typeof value === 'string' ? azureDeletedDate.exec(value) : null;\n\tif (match == null) return undefined;\n\n\tconst [month, day, year, hour, minute, second] = match.slice(1, 7).map(Number);\n\tif (hour < 1 || hour > 12) return undefined;\n\n\tconst date = new Date(Date.UTC(year, month - 1, day, (hour % 12) + (match[7] === 'PM' ? 12 : 0), minute, second));\n\tif (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {\n\t\treturn undefined;\n\t}\n\n\treturn date.toISOString();\n}\n\nfunction readValues<T>(body: { value?: T[] } | undefined): T[] {\n\tif (!Array.isArray(body?.value)) throw new WorkItemWriteError('unknown');\n\n\treturn body.value;\n}\n\nfunction assertExistingAddress(address: WorkItemAddress): void {\n\tif (!isAzurePositiveInt(address.workItemId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertMutationIdentity(expectedAccountId: string): void {\n\tif (!isAzureIdentifier(expectedAccountId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertSameRevision(item: AzureWorkItem, expectedRevision: number): void {\n\tif (!isAzurePositiveInt(expectedRevision)) throw new WorkItemWriteError('invalid-input');\n\tif (item.rev !== expectedRevision) throw new WorkItemWriteError('conflict');\n}\n\nfunction isJsonValue(value: unknown, ancestors = new Set<object>()): boolean {\n\tif (value == null) return value === null;\n\tif (typeof value === 'string' || typeof value === 'boolean') return true;\n\tif (typeof value === 'number') return Number.isFinite(value);\n\tif (typeof value !== 'object' || ancestors.has(value)) return false;\n\tif (\n\t\t!Array.isArray(value) &&\n\t\tObject.getPrototypeOf(value) !== Object.prototype &&\n\t\tObject.getPrototypeOf(value) !== null\n\t) {\n\t\treturn false;\n\t}\n\n\tancestors.add(value);\n\tconst valid = Object.values(value).every(entry => isJsonValue(entry, ancestors));\n\tancestors.delete(value);\n\treturn valid;\n}\n\nfunction isInProjectPath(value: unknown, projectName: string): boolean {\n\tif (typeof value !== 'string') return false;\n\n\tconst root = value.split('\\\\', 1)[0];\n\treturn root.toLowerCase() === projectName.toLowerCase();\n}\n\nfunction getFieldPatches(\n\tinput: Readonly<Record<string, unknown>>,\n\tfieldMetadata: readonly WorkItemWriteField[],\n\tprojectName: string,\n\tcurrent?: Readonly<Record<string, unknown>>,\n): Patch[] {\n\tif (input == null || typeof input !== 'object' || Array.isArray(input)) {\n\t\tthrow new WorkItemWriteError('invalid-input');\n\t}\n\n\tconst fields = new Map(fieldMetadata.map(field => [field.referenceName, field]));\n\tconst errors = new Map<string, string>();\n\tconst patch: Patch[] = [];\n\tfor (const [name, value] of Object.entries(input)) {\n\t\tconst field = fields.get(name);\n\t\tif (field == null || !isJsonValue(value)) {\n\t\t\terrors.set(name, field == null ? 'Field is unavailable for writing.' : 'Expected a JSON field value.');\n\t\t\tcontinue;\n\t\t}\n\t\tif (isAzureProjectPathField(name) && !isInProjectPath(value, projectName)) {\n\t\t\terrors.set(name, 'Expected a path in the selected project.');\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst path = `/fields/${name.replaceAll('~', '~0').replaceAll('/', '~1')}`;\n\t\tif (current != null && value === null) {\n\t\t\tif (Object.hasOwn(current, name)) {\n\t\t\t\tpatch.push({ op: 'remove', path: path });\n\t\t\t}\n\t\t} else {\n\t\t\tpatch.push({ op: 'add', path: path, value: value });\n\t\t}\n\t}\n\tif (current == null) {\n\t\tfor (const field of fieldMetadata) {\n\t\t\tconst value = Object.hasOwn(input, field.referenceName) ? input[field.referenceName] : undefined;\n\t\t\tif (\n\t\t\t\tfield.required &&\n\t\t\t\t(value === null || value === '' || (value === undefined && !Object.hasOwn(field, 'defaultValue')))\n\t\t\t) {\n\t\t\t\terrors.set(field.referenceName, 'This field is required.');\n\t\t\t}\n\t\t}\n\t}\n\tif (errors.size) throw new WorkItemWriteError('invalid-input', Object.fromEntries(errors));\n\n\treturn patch;\n}\n\nasync function readProject(\n\trequest: ProviderRequestFunction,\n\theaders: { Authorization: string },\n\tcollectionUrl: string,\n\tprojectId: string,\n\tapiVersion: string,\n): Promise<{ id: string; name: string }> {\n\tconst { body: project } = await request<{ id?: unknown; name?: unknown }>({\n\t\turl: `${collectionUrl}/_apis/projects/${projectId}?api-version=${apiVersion}`,\n\t\theaders: headers,\n\t\tredirect: 'error',\n\t});\n\tif (!sameAzureIdentifier(project?.id, projectId) || !isAzureIdentifier(project?.name)) {\n\t\tthrow new WorkItemWriteError('not-found');\n\t}\n\n\treturn { id: project.id as string, name: project.name };\n}\n\nexport class AzureWorkItemWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; authorization: string },\n\t\toptions: AzureServicesWorkItemWriteScope,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst { body: profile } = await getAzureWriteProfile(request, credential.accessToken);\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isAzureIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameAzureIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('no-connection');\n\t\t}\n\n\t\tconst headers = { Authorization: credential.authorization };\n\t\tconst { body: accounts } = await getAzureWriteOrganizations(request, credential.authorization, accountId);\n\t\tconst organization = readValues(accounts).find(\n\t\t\taccount =>\n\t\t\t\tsameAzureIdentifier(account.accountId, options.organizationId) &&\n\t\t\t\tsameAzureIdentifier(account.accountName, options.organizationName),\n\t\t);\n\t\tif (organization == null) throw new WorkItemWriteError('not-found');\n\n\t\tconst organizationUrl = `https://dev.azure.com/${encodeAzurePathSegment(organization.accountName)}`;\n\t\tconst project = await readProject(request, headers, organizationUrl, options.projectId, '7.1');\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\taccountId: accountId,\n\t\t\t\torganization: { id: organization.accountId, name: organization.accountName },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\torganizationUrl,\n\t\t\t'7.1',\n\t\t\t() => Promise.resolve('7.1'),\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: AzureServerWorkItemWriteScope,\n\t\tcollectionUrl: string,\n\t\tresolveApiVersion: () => Promise<string | undefined>,\n\t\tresolveStatesApiVersion: () => Promise<string | undefined>,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst headers = { Authorization: authorization };\n\t\tconst { body: data } = await request<AzureServerConnectionData>({\n\t\t\turl: `${collectionUrl}/_apis/connectionData`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tconst accountId = data?.authenticatedUser?.id;\n\t\tconst segment =\n\t\t\ttypeof data?.webApplicationRelativeDirectory === 'string'\n\t\t\t\t? data.webApplicationRelativeDirectory.split('/').findLast(Boolean)\n\t\t\t\t: undefined;\n\t\tconst collectionName = segment != null ? decodeAzurePathSegment(segment) : undefined;\n\t\tif (\n\t\t\t!isAzureGuid(data?.instanceId) ||\n\t\t\t!sameAzureIdentifier(data.instanceId, options.organizationId) ||\n\t\t\tcollectionName == null ||\n\t\t\t!sameAzureIdentifier(collectionName, options.organizationName)\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('not-found');\n\t\t}\n\t\tif (\n\t\t\t!isAzureIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameAzureIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('no-connection');\n\t\t}\n\n\t\tconst apiVersion = await resolveApiVersion();\n\t\tif (apiVersion == null) throw new WorkItemWriteError('unsupported');\n\n\t\tconst project = await readProject(request, headers, collectionUrl, options.projectId, apiVersion);\n\t\tlet statesApiVersion: Promise<string> | undefined;\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\taccountId: accountId,\n\t\t\t\torganization: { id: data.instanceId, name: collectionName, url: collectionUrl },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\tcollectionUrl,\n\t\t\tapiVersion,\n\t\t\t() =>\n\t\t\t\t(statesApiVersion ??= resolveStatesApiVersion().then(version => {\n\t\t\t\t\tif (version == null) throw new WorkItemWriteError('unsupported');\n\n\t\t\t\t\treturn version;\n\t\t\t\t})),\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tprivate readonly projectUrl: string;\n\n\tprivate constructor(\n\t\tprivate readonly request: ProviderRequestFunction,\n\t\tprivate readonly headers: { Authorization: string },\n\t\tprivate readonly context: WorkItemWriteContext,\n\t\tprivate readonly organizationUrl: string,\n\t\tprivate readonly apiVersion: string,\n\t\tprivate readonly getStatesApiVersion: () => Promise<string>,\n\t\tprivate readonly isSessionCurrent: () => Promise<boolean>,\n\t) {\n\t\tthis.projectUrl = `${organizationUrl}/${context.project.id}`;\n\t}\n\n\tasync getCreateOptions(options: WorkItemCreateOptions): Promise<WorkItemCreateOptionsResult> {\n\t\tif (options.workItemType === undefined) {\n\t\t\tconst types = await this.read<{ value?: AzureWorkItemTypeMetadata[] }>('/workitemtypes');\n\t\t\tconst enabled = readValues(types).filter(type => isAzureIdentifier(type.name) && !type.isDisabled);\n\t\t\treturn { ok: true, ...this.context, workItemTypes: enabled.map(type => ({ name: type.name })) };\n\t\t}\n\n\t\tconst { type, fields, states, catalog } = await this.getMetadata(options.workItemType);\n\t\tif (type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tworkItemType: type.name,\n\t\t\tfields: fields,\n\t\t\tstates: states,\n\t\t\tinitialStates: getAzureWorkItemTransitionTargets(type, states, ''),\n\t\t\tbodyField: getAzureWorkItemBodyField(fields, catalog),\n\t\t};\n\t}\n\n\tasync getWriteOptions(options: WorkItemAddress): Promise<WorkItemWriteOptionsResult> {\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\tfields: metadata.fields,\n\t\t\tavailableStates: getAzureWorkItemTransitionTargets(metadata.type, metadata.states, issue.state.name),\n\t\t\tdeleteCapability: await this.getDeleteCapability(metadata.type).catch((): WorkItemDeleteCapability => ({\n\t\t\t\tallowed: 'unknown',\n\t\t\t})),\n\t\t\tbodyField: issue.bodyField,\n\t\t};\n\t}\n\n\tasync resolveTarget(options: WorkItemWriteTargetOptions): Promise<WorkItemWriteTargetResult> {\n\t\tif (options.intent !== undefined && options.intent !== 'delete') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\tconst deleteCapability =\n\t\t\toptions.intent === 'delete' ? await this.getDeleteCapability(metadata.type) : undefined;\n\t\tif (deleteCapability?.allowed === false) throw new WorkItemWriteError(deleteCapability.reason);\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\t...(deleteCapability && { deleteCapability: deleteCapability }),\n\t\t};\n\t}\n\n\tasync write(options: WorkItemWriteOptions): Promise<WorkItemWriteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tif (options.action === 'create') return this.create(options);\n\n\t\tif (options.action !== 'edit' && options.action !== 'set-state') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst patch = getFieldPatches(options.fields ?? {}, metadata.fields, this.context.project.name, item.fields);\n\t\tif (options.action === 'set-state') {\n\t\t\tconst state = this.getReceipt(item, metadata).state.name;\n\t\t\tif (\n\t\t\t\t!getAzureWorkItemTransitionTargets(metadata.type, metadata.states, state).some(\n\t\t\t\t\ts => s.name === options.state,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new WorkItemWriteError('transition-unavailable');\n\t\t\t}\n\n\t\t\tpatch.push({ op: 'add', path: '/fields/System.State', value: options.state });\n\t\t}\n\t\tif (!patch.length) throw new WorkItemWriteError('invalid-input');\n\n\t\tpatch.unshift({ op: 'test', path: '/rev', value: options.expectedRevision });\n\t\treturn this.save('PATCH', `/workitems/${item.id}`, patch, metadata, {\n\t\t\tid: item.id,\n\t\t\tstate: options.action === 'set-state' ? options.state : undefined,\n\t\t});\n\t}\n\n\tasync delete(options: WorkItemDeleteOptions): Promise<WorkItemDeleteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst capability = await this.getDeleteCapability(metadata.type);\n\t\tif (capability.allowed === false) throw new WorkItemWriteError(capability.reason);\n\n\t\tawait this.assertSessionCurrent();\n\t\tconst current = await this.getItem(options);\n\t\tassertSameRevision(current, options.expectedRevision);\n\t\tif (this.itemType(current) !== metadata.type.name) throw new WorkItemWriteError('conflict');\n\n\t\tconst issue = this.getReceipt(current, metadata);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body, status } = await this.request<AzureDeletedWorkItem>({\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl: this.url(`/workitems/${issue.id}`),\n\t\t\t\theaders: this.headers,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tlet deleted =\n\t\t\t\tstatus === 200 && isDeletedItem(body, issue.id) && body.deletedDate != null ? body : undefined;\n\t\t\tif (deleted == null || getDeletedRevision(deleted, issue.id) === undefined) {\n\t\t\t\tconst recycled = await this.read<AzureDeletedWorkItem>(`/recyclebin/${issue.id}`).catch(\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t\tif (isDeletedItem(recycled, issue.id)) {\n\t\t\t\t\tdeleted = recycled;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (deleted == null) return { ok: false, reason: 'unknown', applied: 'maybe' };\n\n\t\t\treturn await this.toDeleteOutcome(deleted, issue, options.expectedRevision);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n\n\tprivate async toDeleteOutcome(\n\t\tdeleted: AzureDeletedWorkItem & { project: string },\n\t\tissue: WorkItemReceipt,\n\t\texpectedRevision: number,\n\t): Promise<WorkItemDeleteResult> {\n\t\tconst revision = getDeletedRevision(deleted, issue.id);\n\t\tconst deletedAt = toDeletedAt(deleted.deletedDate);\n\t\tconst deletion = {\n\t\t\tdisposition: 'recycle-bin',\n\t\t\trestorable: true,\n\t\t\t...(revision !== undefined && { revision: revision }),\n\t\t\t...(deletedAt !== undefined && { deletedAt: deletedAt }),\n\t\t} as const;\n\t\tconst project = sameAzureIdentifier(\n\t\t\tdeleted.project,\n\t\t\tisAzureGuid(deleted.project) ? this.context.project.id : this.context.project.name,\n\t\t)\n\t\t\t? this.context.project\n\t\t\t: await this.findProject(deleted.project);\n\t\tif (sameAzureIdentifier(project.id, this.context.project.id) && revision === expectedRevision + 1) {\n\t\t\treturn { ok: true, ...this.context, issue: issue, deletion: { ...deletion, revision: revision } };\n\t\t}\n\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: 'target-changed',\n\t\t\tapplied: true,\n\t\t\t...this.context,\n\t\t\tdeleted: { id: issue.id, ...(revision !== undefined && { revision: revision }), project: project },\n\t\t\tdeletion: deletion,\n\t\t};\n\t}\n\n\tprivate async findProject(nameOrId: string): Promise<{ id?: string; name: string }> {\n\t\ttry {\n\t\t\tconst project = await this.readOrganization<{ id?: unknown; name?: unknown }>(\n\t\t\t\t`/projects/${encodeAzurePathSegment(nameOrId)}`,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tisAzureGuid(project?.id) &&\n\t\t\t\tisAzureIdentifier(project.name) &&\n\t\t\t\t(sameAzureIdentifier(project.name, nameOrId) || sameAzureIdentifier(project.id, nameOrId))\n\t\t\t) {\n\t\t\t\treturn { id: project.id, name: project.name };\n\t\t\t}\n\t\t} catch {}\n\n\t\treturn { name: nameOrId };\n\t}\n\n\tprivate async create(options: Extract<WorkItemWriteOptions, { action: 'create' }>): Promise<WorkItemWriteResult> {\n\t\tconst metadata = await this.getMetadata(options.workItemType);\n\t\tif (metadata.type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\tconst patch = getFieldPatches(options.fields, metadata.fields, this.context.project.name);\n\t\treturn this.save('POST', `/workitems/$${encodeAzurePathSegment(metadata.type.name)}`, patch, metadata);\n\t}\n\n\tprivate async getDeleteCapability(type: AzureWorkItemTypeMetadata): Promise<WorkItemDeleteCapability> {\n\t\tif (isAzureTestArtifact(type)) return { allowed: false, reason: 'unsupported' };\n\n\t\tconst categories = await this.read<{ value?: AzureWorkItemTypeCategory[] }>('/workitemtypecategories');\n\t\tif (isAzureTestArtifact(type, readValues(categories))) return { allowed: false, reason: 'unsupported' };\n\n\t\ttry {\n\t\t\tconst namespaces = await this.readOrganization<{\n\t\t\t\tvalue?: { namespaceId?: unknown; actions?: { bit?: unknown; name?: unknown }[] }[];\n\t\t\t}>(`/securitynamespaces/${projectSecurityNamespaceId}`);\n\t\t\tconst bit = readValues(namespaces)\n\t\t\t\t.find(namespace => sameAzureIdentifier(namespace?.namespaceId, projectSecurityNamespaceId))\n\t\t\t\t?.actions?.find(action => action?.name === 'WORK_ITEM_DELETE')?.bit;\n\t\t\tif (!isAzurePositiveInt(bit)) return { allowed: 'unknown' };\n\n\t\t\tconst permissions = await this.readOrganization<{ value?: unknown[] }>(\n\t\t\t\t`/permissions/${projectSecurityNamespaceId}/${bit}`,\n\t\t\t\t{\n\t\t\t\t\ttokens: `$PROJECT:vstfs:///Classification/TeamProject/${this.context.project.id}`,\n\t\t\t\t\talwaysAllowAdministrators: 'false',\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst [allowed, ...rest] = readValues(permissions);\n\t\t\tif (typeof allowed !== 'boolean' || rest.length) return { allowed: 'unknown' };\n\n\t\t\treturn allowed ? { allowed: true } : { allowed: false, reason: 'forbidden' };\n\t\t} catch {\n\t\t\treturn { allowed: 'unknown' };\n\t\t}\n\t}\n\n\tprivate async getMetadata(name: string): Promise<WorkItemMetadata> {\n\t\tif (!isAzureIdentifier(name) || name === '.' || name === '..' || /[/\\\\]/.test(name)) {\n\t\t\tthrow new WorkItemWriteError('invalid-input');\n\t\t}\n\n\t\tconst path = `/workitemtypes/${encodeAzurePathSegment(name)}`;\n\t\tconst [type, typeFields, definitions] = await Promise.all([\n\t\t\tthis.read<AzureWorkItemTypeMetadata>(path),\n\t\t\tthis.read<{ value?: AzureWorkItemTypeField[] }>(`${path}/fields`, { $expand: 'All' }),\n\t\t\tthis.read<{ value?: AzureWorkItemFieldDefinition[] }>('/fields'),\n\t\t]);\n\t\tif (!sameAzureIdentifier(type?.name, name) || !isAzureIdentifier(type?.referenceName)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\t\tif (type.transitions == null || typeof type.transitions !== 'object' || Array.isArray(type.transitions)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst states =\n\t\t\tArray.isArray(type.states) && type.states.length !== 0\n\t\t\t\t? type.states\n\t\t\t\t: readValues(\n\t\t\t\t\t\tawait this.read<{ value?: WorkItemState[] }>(`${path}/states`, {\n\t\t\t\t\t\t\t'api-version': await this.getStatesApiVersion(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\tif (states.some(state => !isAzureIdentifier(state?.name) || !isAzureIdentifier(state.category))) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst catalog = readValues(definitions);\n\t\treturn {\n\t\t\ttype: type,\n\t\t\tstates: states.map(({ name, category, color }) => ({\n\t\t\t\tname: name,\n\t\t\t\tcategory: category,\n\t\t\t\t...(typeof color === 'string' && { color: color }),\n\t\t\t})),\n\t\t\tfields: toAzureWorkItemWriteFields(readValues(typeFields), catalog),\n\t\t\tcatalog: catalog,\n\t\t};\n\t}\n\n\tprivate async getItem(options: WorkItemAddress): Promise<AzureWorkItem> {\n\t\tassertExistingAddress(options);\n\t\tconst data = await this.read<AzureWorkItem>(`/workitems/${options.workItemId}`);\n\t\tif (!this.isInProject(data) || data.id !== options.workItemId) throw new WorkItemWriteError('not-found');\n\n\t\treturn data;\n\t}\n\n\tprivate isInProject(item: AzureWorkItem | undefined): item is AzureWorkItem {\n\t\treturn sameAzureIdentifier(item?.fields?.['System.TeamProject'], this.context.project.name);\n\t}\n\n\tprivate itemType(item: AzureWorkItem): string {\n\t\tconst type = item.fields['System.WorkItemType'];\n\t\tif (!isAzureIdentifier(type)) throw new WorkItemWriteError('unknown');\n\n\t\treturn type;\n\t}\n\n\tprivate getReceipt(item: AzureWorkItem, metadata: WorkItemMetadata): WorkItemReceipt {\n\t\tconst title = item.fields['System.Title'];\n\t\tconst state = metadata.states.find(candidate => candidate.name === item.fields['System.State']);\n\t\tif (\n\t\t\t!isAzurePositiveInt(item.id) ||\n\t\t\t!isAzurePositiveInt(item.rev) ||\n\t\t\ttypeof title !== 'string' ||\n\t\t\tstate == null ||\n\t\t\tthis.itemType(item) !== metadata.type.name\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\treturn {\n\t\t\tid: item.id,\n\t\t\trevision: item.rev,\n\t\t\turl: `${this.projectUrl}/_workitems/edit/${item.id}`,\n\t\t\ttype: metadata.type.name,\n\t\t\ttitle: title,\n\t\t\tstate: { name: state.name, category: state.category },\n\t\t\tbodyField: getAzureWorkItemBodyField(metadata.fields, metadata.catalog, item.fields),\n\t\t};\n\t}\n\n\tprivate async assertSessionCurrent(): Promise<void> {\n\t\tif (!(await this.isSessionCurrent())) throw new WorkItemWriteError('no-connection');\n\t}\n\n\tprivate url(path: string, params?: Record<string, string>, base = `${this.projectUrl}/_apis/wit`): string {\n\t\treturn `${base}${path}?${new URLSearchParams({ 'api-version': this.apiVersion, ...params }).toString()}`;\n\t}\n\n\tprivate read<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params));\n\t}\n\n\tprivate readOrganization<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params, `${this.organizationUrl}/_apis`));\n\t}\n\n\tprivate async get<T>(url: string): Promise<T> {\n\t\tconst { body } = await this.request<T>({ url: url, headers: this.headers, redirect: 'error' });\n\t\treturn body;\n\t}\n\n\tprivate async save(\n\t\tmethod: 'POST' | 'PATCH',\n\t\tpath: string,\n\t\tpatch: Patch[],\n\t\tmetadata: WorkItemMetadata,\n\t\texpected?: { id: number; state?: string },\n\t): Promise<WorkItemWriteResult> {\n\t\tconst body = JSON.stringify(patch);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body: item } = await this.request<AzureWorkItem>({\n\t\t\t\tmethod: method,\n\t\t\t\turl: this.url(path),\n\t\t\t\theaders: { ...this.headers, 'Content-Type': 'application/json-patch+json' },\n\t\t\t\tbody: body,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tif (\n\t\t\t\t!this.isInProject(item) ||\n\t\t\t\t(expected != null && item.id !== expected.id) ||\n\t\t\t\t(expected?.state !== undefined && item.fields['System.State'] !== expected.state)\n\t\t\t) {\n\t\t\t\treturn { ok: false, reason: 'unknown', applied: 'maybe' };\n\t\t\t}\n\n\t\t\treturn { ok: true, ...this.context, issue: this.getReceipt(item, metadata) };\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAuEA,MA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;CAEA,iBAA4B,MAAc,QAA6C;EACtF,OAAO,KAAK,IAAO,KAAK,IAAI,MAAM,QAAQ,GAAG,KAAK,gBAAgB,OAAO,CAAC;CAC3E;CAEA,MAAc,IAAO,KAAyB;EAC7C,MAAM,EAAE,SAAS,MAAM,KAAK,QAAW;GAAO;GAAK,SAAS,KAAK;GAAS,UAAU;EAAQ,CAAC;EAC7F,OAAO;CACR;CAEA,MAAc,KACb,QACA,MACA,OACA,UACA,UAC+B;EAC/B,MAAM,OAAO,KAAK,UAAU,KAAK;EACjC,MAAM,KAAK,qBAAqB;EAChC,IAAI;GACH,MAAM,EAAE,MAAM,SAAS,MAAM,KAAK,QAAuB;IAChD;IACR,KAAK,KAAK,IAAI,IAAI;IAClB,SAAS;KAAE,GAAG,KAAK;KAAS,gBAAgB;IAA8B;IACpE;IACN,UAAU;GACX,CAAC;GACD,IACC,CAAC,KAAK,YAAY,IAAI,KACrB,YAAY,QAAQ,KAAK,OAAO,SAAS,MACzC,UAAU,UAAU,KAAA,KAAa,KAAK,OAAO,oBAAoB,SAAS,OAE3E,OAAO;IAAE,IAAI;IAAO,QAAQ;IAAW,SAAS;GAAQ;GAGzD,OAAO;IAAE,IAAI;IAAM,GAAG,KAAK;IAAS,OAAO,KAAK,WAAW,MAAM,QAAQ;GAAE;EAC5E,SAAS,IAAI;GACZ,IAAI,cAAc,iCAAiC,OAAO,uBAAuB,EAAE;GAEnF,OAAO,uBAAuB,IAAI,EAAE,QAAQ,SAAS,OAAO,CAAC;EAC9D;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"azureWorkItemWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWrites.ts"],"sourcesContent":["import type {\n\tAzureServerWorkItemWriteScope,\n\tAzureServicesWorkItemWriteScope,\n\tWorkItemAddress,\n\tWorkItemCreateOptions,\n\tWorkItemCreateOptionsResult,\n\tWorkItemDeleteCapability,\n\tWorkItemDeleteOptions,\n\tWorkItemDeleteResult,\n\tWorkItemReceipt,\n\tWorkItemState,\n\tWorkItemWriteContext,\n\tWorkItemWriteField,\n\tWorkItemWriteOptions,\n\tWorkItemWriteOptionsResult,\n\tWorkItemWriteResult,\n\tWorkItemWriteTargetOptions,\n\tWorkItemWriteTargetResult,\n} from '../models/workItemWrites.js';\nimport { encodeAzurePathSegment } from './azure/models.js';\nimport type {\n\tAzureWorkItemFieldDefinition,\n\tAzureWorkItemTypeCategory,\n\tAzureWorkItemTypeField,\n\tAzureWorkItemTypeMetadata,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWorkItemBodyField,\n\tgetAzureWorkItemTransitionTargets,\n\tisAzureProjectPathField,\n\tisAzureTestArtifact,\n\ttoAzureWorkItemWriteFields,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tisAzureIdentifier,\n\tisAzurePositiveInt,\n\tsameAzureIdentifier,\n\tverifyAzureServerCollection,\n} from './azure/writeIdentity.js';\nimport {\n\ttoWorkItemWriteFailure,\n\tWorkItemWriteError,\n\tWorkItemWriteNotDispatchedError,\n} from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.js';\n\ntype AzureWorkItem = { id: number; rev: number; fields: Readonly<Record<string, unknown>> };\ntype AzureDeletedWorkItem = {\n\tid?: unknown;\n\tproject?: unknown;\n\tdeletedDate?: unknown;\n\tcode?: unknown;\n\tresource?: { id?: unknown; rev?: unknown };\n};\ntype WorkItemMetadata = {\n\ttype: AzureWorkItemTypeMetadata;\n\tstates: readonly WorkItemState[];\n\tfields: readonly WorkItemWriteField[];\n\tcatalog: readonly AzureWorkItemFieldDefinition[];\n};\ntype Patch = { op: 'add' | 'test'; path: string; value: unknown } | { op: 'remove'; path: string };\n\nconst projectSecurityNamespaceId = '52d39943-cb85-4d7f-8fa8-c6baac873819';\n\nfunction isSameId(actual: unknown, id: number): boolean {\n\treturn actual === id || actual === String(id);\n}\n\nfunction isDeletedItem(\n\titem: AzureDeletedWorkItem | undefined,\n\tid: number,\n): item is AzureDeletedWorkItem & { project: string } {\n\tif (item == null || !isSameId(item.id, id) || !isAzureIdentifier(item.project)) return false;\n\n\treturn (\n\t\titem.code == null || item.code === 0 || (typeof item.code === 'number' && item.code >= 200 && item.code < 300)\n\t);\n}\n\nfunction getDeletedRevision(item: AzureDeletedWorkItem, id: number): number | undefined {\n\tconst resource = item.resource;\n\treturn resource != null && isSameId(resource.id, id) && isAzurePositiveInt(resource.rev) ? resource.rev : undefined;\n}\n\n// SEE: Azure reports `deletedDate` as a zone-less en-US UTC string (\"11/25/2026 6:24:35 PM\"), observed live.\nconst azureDeletedDate = /^(\\d{1,2})\\/(\\d{1,2})\\/([12]\\d{3}) (\\d{1,2}):([0-5]\\d):([0-5]\\d) (AM|PM)$/;\n\nfunction toDeletedAt(value: unknown): string | undefined {\n\tconst match = typeof value === 'string' ? azureDeletedDate.exec(value) : null;\n\tif (match == null) return undefined;\n\n\tconst [month, day, year, hour, minute, second] = match.slice(1, 7).map(Number);\n\tif (hour < 1 || hour > 12) return undefined;\n\n\tconst date = new Date(Date.UTC(year, month - 1, day, (hour % 12) + (match[7] === 'PM' ? 12 : 0), minute, second));\n\tif (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {\n\t\treturn undefined;\n\t}\n\n\treturn date.toISOString();\n}\n\nfunction readValues<T>(body: { value?: T[] } | undefined): T[] {\n\tif (!Array.isArray(body?.value)) throw new WorkItemWriteError('unknown');\n\n\treturn body.value;\n}\n\nfunction assertExistingAddress(address: WorkItemAddress): void {\n\tif (!isAzurePositiveInt(address.workItemId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertMutationIdentity(expectedAccountId: string): void {\n\tif (!isAzureIdentifier(expectedAccountId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertSameRevision(item: AzureWorkItem, expectedRevision: number): void {\n\tif (!isAzurePositiveInt(expectedRevision)) throw new WorkItemWriteError('invalid-input');\n\tif (item.rev !== expectedRevision) throw new WorkItemWriteError('conflict');\n}\n\nfunction isJsonValue(value: unknown, ancestors = new Set<object>()): boolean {\n\tif (value == null) return value === null;\n\tif (typeof value === 'string' || typeof value === 'boolean') return true;\n\tif (typeof value === 'number') return Number.isFinite(value);\n\tif (typeof value !== 'object' || ancestors.has(value)) return false;\n\tif (\n\t\t!Array.isArray(value) &&\n\t\tObject.getPrototypeOf(value) !== Object.prototype &&\n\t\tObject.getPrototypeOf(value) !== null\n\t) {\n\t\treturn false;\n\t}\n\n\tancestors.add(value);\n\tconst valid = Object.values(value).every(entry => isJsonValue(entry, ancestors));\n\tancestors.delete(value);\n\treturn valid;\n}\n\nfunction isInProjectPath(value: unknown, projectName: string): boolean {\n\tif (typeof value !== 'string') return false;\n\n\tconst root = value.split('\\\\', 1)[0];\n\treturn root.toLowerCase() === projectName.toLowerCase();\n}\n\nfunction getFieldPatches(\n\tinput: Readonly<Record<string, unknown>>,\n\tfieldMetadata: readonly WorkItemWriteField[],\n\tprojectName: string,\n\tcurrent?: Readonly<Record<string, unknown>>,\n): Patch[] {\n\tif (input == null || typeof input !== 'object' || Array.isArray(input)) {\n\t\tthrow new WorkItemWriteError('invalid-input');\n\t}\n\n\tconst fields = new Map(fieldMetadata.map(field => [field.referenceName, field]));\n\tconst errors = new Map<string, string>();\n\tconst patch: Patch[] = [];\n\tfor (const [name, value] of Object.entries(input)) {\n\t\tconst field = fields.get(name);\n\t\tif (field == null || !isJsonValue(value)) {\n\t\t\terrors.set(name, field == null ? 'Field is unavailable for writing.' : 'Expected a JSON field value.');\n\t\t\tcontinue;\n\t\t}\n\t\tif (isAzureProjectPathField(name) && !isInProjectPath(value, projectName)) {\n\t\t\terrors.set(name, 'Expected a path in the selected project.');\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst path = `/fields/${name.replaceAll('~', '~0').replaceAll('/', '~1')}`;\n\t\tif (current != null && value === null) {\n\t\t\tif (Object.hasOwn(current, name)) {\n\t\t\t\tpatch.push({ op: 'remove', path: path });\n\t\t\t}\n\t\t} else {\n\t\t\tpatch.push({ op: 'add', path: path, value: value });\n\t\t}\n\t}\n\tif (current == null) {\n\t\tfor (const field of fieldMetadata) {\n\t\t\tconst value = Object.hasOwn(input, field.referenceName) ? input[field.referenceName] : undefined;\n\t\t\tif (\n\t\t\t\tfield.required &&\n\t\t\t\t(value === null || value === '' || (value === undefined && !Object.hasOwn(field, 'defaultValue')))\n\t\t\t) {\n\t\t\t\terrors.set(field.referenceName, 'This field is required.');\n\t\t\t}\n\t\t}\n\t}\n\tif (errors.size) throw new WorkItemWriteError('invalid-input', Object.fromEntries(errors));\n\n\treturn patch;\n}\n\nasync function readProject(\n\trequest: ProviderRequestFunction,\n\theaders: { Authorization: string },\n\tcollectionUrl: string,\n\tprojectId: string,\n\tapiVersion: string,\n): Promise<{ id: string; name: string }> {\n\tconst { body: project } = await request<{ id?: unknown; name?: unknown }>({\n\t\turl: `${collectionUrl}/_apis/projects/${projectId}?api-version=${apiVersion}`,\n\t\theaders: headers,\n\t\tredirect: 'error',\n\t});\n\tif (!sameAzureIdentifier(project?.id, projectId) || !isAzureIdentifier(project?.name)) {\n\t\tthrow new WorkItemWriteError('not-found');\n\t}\n\n\treturn { id: project.id as string, name: project.name };\n}\n\nexport class AzureWorkItemWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; authorization: string },\n\t\toptions: AzureServicesWorkItemWriteScope,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst { body: profile } = await getAzureWriteProfile(request, credential.accessToken);\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isAzureIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameAzureIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('no-connection');\n\t\t}\n\n\t\tconst headers = { Authorization: credential.authorization };\n\t\tconst { body: accounts } = await getAzureWriteOrganizations(request, credential.authorization, accountId);\n\t\tconst organization = readValues(accounts).find(\n\t\t\taccount =>\n\t\t\t\tsameAzureIdentifier(account.accountId, options.organizationId) &&\n\t\t\t\tsameAzureIdentifier(account.accountName, options.organizationName),\n\t\t);\n\t\tif (organization == null) throw new WorkItemWriteError('not-found');\n\n\t\tconst organizationUrl = `https://dev.azure.com/${encodeAzurePathSegment(organization.accountName)}`;\n\t\tconst project = await readProject(request, headers, organizationUrl, options.projectId, '7.1');\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\taccountId: accountId,\n\t\t\t\torganization: { id: organization.accountId, name: organization.accountName },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\torganizationUrl,\n\t\t\t'7.1',\n\t\t\t() => Promise.resolve('7.1'),\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: AzureServerWorkItemWriteScope,\n\t\tcollectionUrl: string,\n\t\tresolveApiVersion: () => Promise<string | undefined>,\n\t\tresolveStatesApiVersion: () => Promise<string | undefined>,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst headers = { Authorization: authorization };\n\t\tconst collection = await verifyAzureServerCollection(request, headers, collectionUrl, options);\n\t\tif (typeof collection === 'string') throw new WorkItemWriteError(collection);\n\n\t\tconst apiVersion = await resolveApiVersion();\n\t\tif (apiVersion == null) throw new WorkItemWriteError('unsupported');\n\n\t\tconst project = await readProject(request, headers, collectionUrl, options.projectId, apiVersion);\n\t\tlet statesApiVersion: Promise<string> | undefined;\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\taccountId: collection.accountId,\n\t\t\t\torganization: { id: collection.id, name: collection.name, url: collectionUrl },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\tcollectionUrl,\n\t\t\tapiVersion,\n\t\t\t() =>\n\t\t\t\t(statesApiVersion ??= resolveStatesApiVersion().then(version => {\n\t\t\t\t\tif (version == null) throw new WorkItemWriteError('unsupported');\n\n\t\t\t\t\treturn version;\n\t\t\t\t})),\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tprivate readonly projectUrl: string;\n\n\tprivate constructor(\n\t\tprivate readonly request: ProviderRequestFunction,\n\t\tprivate readonly headers: { Authorization: string },\n\t\tprivate readonly context: WorkItemWriteContext,\n\t\tprivate readonly organizationUrl: string,\n\t\tprivate readonly apiVersion: string,\n\t\tprivate readonly getStatesApiVersion: () => Promise<string>,\n\t\tprivate readonly isSessionCurrent: () => Promise<boolean>,\n\t) {\n\t\tthis.projectUrl = `${organizationUrl}/${context.project.id}`;\n\t}\n\n\tasync getCreateOptions(options: WorkItemCreateOptions): Promise<WorkItemCreateOptionsResult> {\n\t\tif (options.workItemType === undefined) {\n\t\t\tconst types = await this.read<{ value?: AzureWorkItemTypeMetadata[] }>('/workitemtypes');\n\t\t\tconst enabled = readValues(types).filter(type => isAzureIdentifier(type.name) && !type.isDisabled);\n\t\t\treturn { ok: true, ...this.context, workItemTypes: enabled.map(type => ({ name: type.name })) };\n\t\t}\n\n\t\tconst { type, fields, states, catalog } = await this.getMetadata(options.workItemType);\n\t\tif (type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tworkItemType: type.name,\n\t\t\tfields: fields,\n\t\t\tstates: states,\n\t\t\tinitialStates: getAzureWorkItemTransitionTargets(type, states, ''),\n\t\t\tbodyField: getAzureWorkItemBodyField(fields, catalog),\n\t\t};\n\t}\n\n\tasync getWriteOptions(options: WorkItemAddress): Promise<WorkItemWriteOptionsResult> {\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\tfields: metadata.fields,\n\t\t\tavailableStates: getAzureWorkItemTransitionTargets(metadata.type, metadata.states, issue.state.name),\n\t\t\tdeleteCapability: await this.getDeleteCapability(metadata.type).catch((): WorkItemDeleteCapability => ({\n\t\t\t\tallowed: 'unknown',\n\t\t\t})),\n\t\t\tbodyField: issue.bodyField,\n\t\t};\n\t}\n\n\tasync resolveTarget(options: WorkItemWriteTargetOptions): Promise<WorkItemWriteTargetResult> {\n\t\tif (options.intent !== undefined && options.intent !== 'delete') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\tconst deleteCapability =\n\t\t\toptions.intent === 'delete' ? await this.getDeleteCapability(metadata.type) : undefined;\n\t\tif (deleteCapability?.allowed === false) throw new WorkItemWriteError(deleteCapability.reason);\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\t...(deleteCapability && { deleteCapability: deleteCapability }),\n\t\t};\n\t}\n\n\tasync write(options: WorkItemWriteOptions): Promise<WorkItemWriteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tif (options.action === 'create') return this.create(options);\n\n\t\tif (options.action !== 'edit' && options.action !== 'set-state') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst patch = getFieldPatches(options.fields ?? {}, metadata.fields, this.context.project.name, item.fields);\n\t\tif (options.action === 'set-state') {\n\t\t\tconst state = this.getReceipt(item, metadata).state.name;\n\t\t\tif (\n\t\t\t\t!getAzureWorkItemTransitionTargets(metadata.type, metadata.states, state).some(\n\t\t\t\t\ts => s.name === options.state,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new WorkItemWriteError('transition-unavailable');\n\t\t\t}\n\n\t\t\tpatch.push({ op: 'add', path: '/fields/System.State', value: options.state });\n\t\t}\n\t\tif (!patch.length) throw new WorkItemWriteError('invalid-input');\n\n\t\tpatch.unshift({ op: 'test', path: '/rev', value: options.expectedRevision });\n\t\treturn this.save('PATCH', `/workitems/${item.id}`, patch, metadata, {\n\t\t\tid: item.id,\n\t\t\tstate: options.action === 'set-state' ? options.state : undefined,\n\t\t});\n\t}\n\n\tasync delete(options: WorkItemDeleteOptions): Promise<WorkItemDeleteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst capability = await this.getDeleteCapability(metadata.type);\n\t\tif (capability.allowed === false) throw new WorkItemWriteError(capability.reason);\n\n\t\tawait this.assertSessionCurrent();\n\t\tconst current = await this.getItem(options);\n\t\tassertSameRevision(current, options.expectedRevision);\n\t\tif (this.itemType(current) !== metadata.type.name) throw new WorkItemWriteError('conflict');\n\n\t\tconst issue = this.getReceipt(current, metadata);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body, status } = await this.request<AzureDeletedWorkItem>({\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl: this.url(`/workitems/${issue.id}`),\n\t\t\t\theaders: this.headers,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tlet deleted =\n\t\t\t\tstatus === 200 && isDeletedItem(body, issue.id) && body.deletedDate != null ? body : undefined;\n\t\t\tif (deleted == null || getDeletedRevision(deleted, issue.id) === undefined) {\n\t\t\t\tconst recycled = await this.read<AzureDeletedWorkItem>(`/recyclebin/${issue.id}`).catch(\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t\tif (isDeletedItem(recycled, issue.id)) {\n\t\t\t\t\tdeleted = recycled;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (deleted == null) return { ok: false, reason: 'unknown', applied: 'maybe' };\n\n\t\t\treturn await this.toDeleteOutcome(deleted, issue, options.expectedRevision);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n\n\tprivate async toDeleteOutcome(\n\t\tdeleted: AzureDeletedWorkItem & { project: string },\n\t\tissue: WorkItemReceipt,\n\t\texpectedRevision: number,\n\t): Promise<WorkItemDeleteResult> {\n\t\tconst revision = getDeletedRevision(deleted, issue.id);\n\t\tconst deletedAt = toDeletedAt(deleted.deletedDate);\n\t\tconst deletion = {\n\t\t\tdisposition: 'recycle-bin',\n\t\t\trestorable: true,\n\t\t\t...(revision !== undefined && { revision: revision }),\n\t\t\t...(deletedAt !== undefined && { deletedAt: deletedAt }),\n\t\t} as const;\n\t\tconst project = sameAzureIdentifier(\n\t\t\tdeleted.project,\n\t\t\tisAzureGuid(deleted.project) ? this.context.project.id : this.context.project.name,\n\t\t)\n\t\t\t? this.context.project\n\t\t\t: await this.findProject(deleted.project);\n\t\tif (sameAzureIdentifier(project.id, this.context.project.id) && revision === expectedRevision + 1) {\n\t\t\treturn { ok: true, ...this.context, issue: issue, deletion: { ...deletion, revision: revision } };\n\t\t}\n\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: 'target-changed',\n\t\t\tapplied: true,\n\t\t\t...this.context,\n\t\t\tdeleted: { id: issue.id, ...(revision !== undefined && { revision: revision }), project: project },\n\t\t\tdeletion: deletion,\n\t\t};\n\t}\n\n\tprivate async findProject(nameOrId: string): Promise<{ id?: string; name: string }> {\n\t\ttry {\n\t\t\tconst project = await this.readOrganization<{ id?: unknown; name?: unknown }>(\n\t\t\t\t`/projects/${encodeAzurePathSegment(nameOrId)}`,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tisAzureGuid(project?.id) &&\n\t\t\t\tisAzureIdentifier(project.name) &&\n\t\t\t\t(sameAzureIdentifier(project.name, nameOrId) || sameAzureIdentifier(project.id, nameOrId))\n\t\t\t) {\n\t\t\t\treturn { id: project.id, name: project.name };\n\t\t\t}\n\t\t} catch {}\n\n\t\treturn { name: nameOrId };\n\t}\n\n\tprivate async create(options: Extract<WorkItemWriteOptions, { action: 'create' }>): Promise<WorkItemWriteResult> {\n\t\tconst metadata = await this.getMetadata(options.workItemType);\n\t\tif (metadata.type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\tconst patch = getFieldPatches(options.fields, metadata.fields, this.context.project.name);\n\t\treturn this.save('POST', `/workitems/$${encodeAzurePathSegment(metadata.type.name)}`, patch, metadata);\n\t}\n\n\tprivate async getDeleteCapability(type: AzureWorkItemTypeMetadata): Promise<WorkItemDeleteCapability> {\n\t\tif (isAzureTestArtifact(type)) return { allowed: false, reason: 'unsupported' };\n\n\t\tconst categories = await this.read<{ value?: AzureWorkItemTypeCategory[] }>('/workitemtypecategories');\n\t\tif (isAzureTestArtifact(type, readValues(categories))) return { allowed: false, reason: 'unsupported' };\n\n\t\ttry {\n\t\t\tconst namespaces = await this.readOrganization<{\n\t\t\t\tvalue?: { namespaceId?: unknown; actions?: { bit?: unknown; name?: unknown }[] }[];\n\t\t\t}>(`/securitynamespaces/${projectSecurityNamespaceId}`);\n\t\t\tconst bit = readValues(namespaces)\n\t\t\t\t.find(namespace => sameAzureIdentifier(namespace?.namespaceId, projectSecurityNamespaceId))\n\t\t\t\t?.actions?.find(action => action?.name === 'WORK_ITEM_DELETE')?.bit;\n\t\t\tif (!isAzurePositiveInt(bit)) return { allowed: 'unknown' };\n\n\t\t\tconst permissions = await this.readOrganization<{ value?: unknown[] }>(\n\t\t\t\t`/permissions/${projectSecurityNamespaceId}/${bit}`,\n\t\t\t\t{\n\t\t\t\t\ttokens: `$PROJECT:vstfs:///Classification/TeamProject/${this.context.project.id}`,\n\t\t\t\t\talwaysAllowAdministrators: 'false',\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst [allowed, ...rest] = readValues(permissions);\n\t\t\tif (typeof allowed !== 'boolean' || rest.length) return { allowed: 'unknown' };\n\n\t\t\treturn allowed ? { allowed: true } : { allowed: false, reason: 'forbidden' };\n\t\t} catch {\n\t\t\treturn { allowed: 'unknown' };\n\t\t}\n\t}\n\n\tprivate async getMetadata(name: string): Promise<WorkItemMetadata> {\n\t\tif (!isAzureIdentifier(name) || name === '.' || name === '..' || /[/\\\\]/.test(name)) {\n\t\t\tthrow new WorkItemWriteError('invalid-input');\n\t\t}\n\n\t\tconst path = `/workitemtypes/${encodeAzurePathSegment(name)}`;\n\t\tconst [type, typeFields, definitions] = await Promise.all([\n\t\t\tthis.read<AzureWorkItemTypeMetadata>(path),\n\t\t\tthis.read<{ value?: AzureWorkItemTypeField[] }>(`${path}/fields`, { $expand: 'All' }),\n\t\t\tthis.read<{ value?: AzureWorkItemFieldDefinition[] }>('/fields'),\n\t\t]);\n\t\tif (!sameAzureIdentifier(type?.name, name) || !isAzureIdentifier(type?.referenceName)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\t\tif (type.transitions == null || typeof type.transitions !== 'object' || Array.isArray(type.transitions)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst states =\n\t\t\tArray.isArray(type.states) && type.states.length !== 0\n\t\t\t\t? type.states\n\t\t\t\t: readValues(\n\t\t\t\t\t\tawait this.read<{ value?: WorkItemState[] }>(`${path}/states`, {\n\t\t\t\t\t\t\t'api-version': await this.getStatesApiVersion(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\tif (states.some(state => !isAzureIdentifier(state?.name) || !isAzureIdentifier(state.category))) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst catalog = readValues(definitions);\n\t\treturn {\n\t\t\ttype: type,\n\t\t\tstates: states.map(({ name, category, color }) => ({\n\t\t\t\tname: name,\n\t\t\t\tcategory: category,\n\t\t\t\t...(typeof color === 'string' && { color: color }),\n\t\t\t})),\n\t\t\tfields: toAzureWorkItemWriteFields(readValues(typeFields), catalog),\n\t\t\tcatalog: catalog,\n\t\t};\n\t}\n\n\tprivate async getItem(options: WorkItemAddress): Promise<AzureWorkItem> {\n\t\tassertExistingAddress(options);\n\t\tconst data = await this.read<AzureWorkItem>(`/workitems/${options.workItemId}`);\n\t\tif (!this.isInProject(data) || data.id !== options.workItemId) throw new WorkItemWriteError('not-found');\n\n\t\treturn data;\n\t}\n\n\tprivate isInProject(item: AzureWorkItem | undefined): item is AzureWorkItem {\n\t\treturn sameAzureIdentifier(item?.fields?.['System.TeamProject'], this.context.project.name);\n\t}\n\n\tprivate itemType(item: AzureWorkItem): string {\n\t\tconst type = item.fields['System.WorkItemType'];\n\t\tif (!isAzureIdentifier(type)) throw new WorkItemWriteError('unknown');\n\n\t\treturn type;\n\t}\n\n\tprivate getReceipt(item: AzureWorkItem, metadata: WorkItemMetadata): WorkItemReceipt {\n\t\tconst title = item.fields['System.Title'];\n\t\tconst state = metadata.states.find(candidate => candidate.name === item.fields['System.State']);\n\t\tif (\n\t\t\t!isAzurePositiveInt(item.id) ||\n\t\t\t!isAzurePositiveInt(item.rev) ||\n\t\t\ttypeof title !== 'string' ||\n\t\t\tstate == null ||\n\t\t\tthis.itemType(item) !== metadata.type.name\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\treturn {\n\t\t\tid: item.id,\n\t\t\trevision: item.rev,\n\t\t\turl: `${this.projectUrl}/_workitems/edit/${item.id}`,\n\t\t\ttype: metadata.type.name,\n\t\t\ttitle: title,\n\t\t\tstate: { name: state.name, category: state.category },\n\t\t\tbodyField: getAzureWorkItemBodyField(metadata.fields, metadata.catalog, item.fields),\n\t\t};\n\t}\n\n\tprivate async assertSessionCurrent(): Promise<void> {\n\t\tif (!(await this.isSessionCurrent())) throw new WorkItemWriteError('no-connection');\n\t}\n\n\tprivate url(path: string, params?: Record<string, string>, base = `${this.projectUrl}/_apis/wit`): string {\n\t\treturn `${base}${path}?${new URLSearchParams({ 'api-version': this.apiVersion, ...params }).toString()}`;\n\t}\n\n\tprivate read<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params));\n\t}\n\n\tprivate readOrganization<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params, `${this.organizationUrl}/_apis`));\n\t}\n\n\tprivate async get<T>(url: string): Promise<T> {\n\t\tconst { body } = await this.request<T>({ url: url, headers: this.headers, redirect: 'error' });\n\t\treturn body;\n\t}\n\n\tprivate async save(\n\t\tmethod: 'POST' | 'PATCH',\n\t\tpath: string,\n\t\tpatch: Patch[],\n\t\tmetadata: WorkItemMetadata,\n\t\texpected?: { id: number; state?: string },\n\t): Promise<WorkItemWriteResult> {\n\t\tconst body = JSON.stringify(patch);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body: item } = await this.request<AzureWorkItem>({\n\t\t\t\tmethod: method,\n\t\t\t\turl: this.url(path),\n\t\t\t\theaders: { ...this.headers, 'Content-Type': 'application/json-patch+json' },\n\t\t\t\tbody: body,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tif (\n\t\t\t\t!this.isInProject(item) ||\n\t\t\t\t(expected != null && item.id !== expected.id) ||\n\t\t\t\t(expected?.state !== undefined && item.fields['System.State'] !== expected.state)\n\t\t\t) {\n\t\t\t\treturn { ok: false, reason: 'unknown', applied: 'maybe' };\n\t\t\t}\n\n\t\t\treturn { ok: true, ...this.context, issue: this.getReceipt(item, metadata) };\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}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,KAAK,IAAI,IAAI;IAClB,SAAS;KAAE,GAAG,KAAK;KAAS,gBAAgB;IAA8B;IACpE;IACN,UAAU;GACX,CAAC;GACD,IACC,CAAC,KAAK,YAAY,IAAI,KACrB,YAAY,QAAQ,KAAK,OAAO,SAAS,MACzC,UAAU,UAAU,KAAA,KAAa,KAAK,OAAO,oBAAoB,SAAS,OAE3E,OAAO;IAAE,IAAI;IAAO,QAAQ;IAAW,SAAS;GAAQ;GAGzD,OAAO;IAAE,IAAI;IAAM,GAAG,KAAK;IAAS,OAAO,KAAK,WAAW,MAAM,QAAQ;GAAE;EAC5E,SAAS,IAAI;GACZ,IAAI,cAAc,iCAAiC,OAAO,uBAAuB,EAAE;GAEnF,OAAO,uBAAuB,IAAI,EAAE,QAAQ,SAAS,OAAO,CAAC;EAC9D;CACD;AACD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IssueSorting } from "../../../git/models/issue.js";
|
|
2
|
+
import "../providerFilters.js";
|
|
2
3
|
//#region ../plus/integrations/src/providers/issueSorts.d.ts
|
|
3
4
|
/** GitHub and GHE: one `search` channel serves all three issue reads, so all three order the same way. */
|
|
4
5
|
export declare const githubIssueSorts: IssueSorting[];
|
|
@@ -64,7 +64,8 @@ const githubPullRequestSearchCapabilities = {
|
|
|
64
64
|
"updated:asc",
|
|
65
65
|
"created:desc",
|
|
66
66
|
"created:asc"
|
|
67
|
-
]
|
|
67
|
+
],
|
|
68
|
+
changedSince: true
|
|
68
69
|
};
|
|
69
70
|
/**
|
|
70
71
|
* Bitbucket Data Center's filtered pull-request search (`bitbucket-server/pullRequestSearch.ts`), declared from what
|
|
@@ -96,7 +97,8 @@ const bitbucketServerPullRequestSearchCapabilities = {
|
|
|
96
97
|
draft: true,
|
|
97
98
|
repositoryScope: true,
|
|
98
99
|
organizationScope: false,
|
|
99
|
-
sorts: ["updated:desc", "updated:asc"]
|
|
100
|
+
sorts: ["updated:desc", "updated:asc"],
|
|
101
|
+
changedSince: false
|
|
100
102
|
};
|
|
101
103
|
/**
|
|
102
104
|
* Azure DevOps Server's filtered pull-request search. Azure's pull request query narrows only by creator, reviewer,
|
|
@@ -128,7 +130,8 @@ const azureServerPullRequestSearchCapabilities = {
|
|
|
128
130
|
draft: true,
|
|
129
131
|
repositoryScope: true,
|
|
130
132
|
organizationScope: true,
|
|
131
|
-
sorts: azurePullRequestSearchSorts
|
|
133
|
+
sorts: azurePullRequestSearchSorts,
|
|
134
|
+
changedSince: false
|
|
132
135
|
};
|
|
133
136
|
/**
|
|
134
137
|
* Azure DevOps Server's filtered work-item search: one WIQL query per collection, every criterion a clause of it.
|