UNPKG

@tiberriver256/mcp-server-azure-devops

Version:

Azure DevOps reference server for the Model Context Protocol (MCP)

87 lines 3.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updatePullRequestThreadStatus = updatePullRequestThreadStatus; const errors_1 = require("../../../shared/errors"); const enums_1 = require("../../../shared/enums"); /** * Update the status of a pull request comment thread * * @param connection The Azure DevOps WebApi connection * @param projectId The ID or name of the project * @param repositoryId The ID or name of the repository (optional) * @param pullRequestId The ID of the pull request * @param threadId The ID of the thread to update * @param options Options containing the new status * @returns The updated comment thread */ async function updatePullRequestThreadStatus(connection, projectId, repositoryId, pullRequestId, threadId, options) { try { const gitApi = await connection.getGitApi(); const project = projectId || undefined; let resolvedRepositoryId = repositoryId || options.repositoryId; if (!resolvedRepositoryId) { const pr = await gitApi.getPullRequestById(pullRequestId, project); resolvedRepositoryId = pr?.repository?.id; } if (!resolvedRepositoryId) { throw new Error('repositoryId is required (or must be derivable from pullRequestId)'); } // Map status string to CommentThreadStatus enum using commentThreadStatusMapper const mappedStatus = enums_1.commentThreadStatusMapper.toEnum(options.status); if (mappedStatus === undefined) { throw new Error(`Invalid status value: ${options.status}`); } // Create the updated thread payload const threadUpdate = { status: mappedStatus, }; const updatedThread = await gitApi.updateThread(threadUpdate, resolvedRepositoryId, pullRequestId, threadId, project); if (!updatedThread) { throw new Error('Failed to update pull request thread status'); } // Transform comments inside the thread to have string enums const transformedComments = updatedThread.comments?.map((comment) => { // Get file path and positions from thread context if applicable const filePath = updatedThread.threadContext?.filePath; const leftFileStart = updatedThread.threadContext && 'leftFileStart' in updatedThread.threadContext ? updatedThread.threadContext.leftFileStart : undefined; const leftFileEnd = updatedThread.threadContext && 'leftFileEnd' in updatedThread.threadContext ? updatedThread.threadContext.leftFileEnd : undefined; const rightFileStart = updatedThread.threadContext && 'rightFileStart' in updatedThread.threadContext ? updatedThread.threadContext.rightFileStart : undefined; const rightFileEnd = updatedThread.threadContext && 'rightFileEnd' in updatedThread.threadContext ? updatedThread.threadContext.rightFileEnd : undefined; return { ...comment, filePath, leftFileStart, leftFileEnd, rightFileStart, rightFileEnd, commentType: (0, enums_1.transformCommentType)(comment.commentType), }; }); return { thread: { ...updatedThread, status: (0, enums_1.transformCommentThreadStatus)(updatedThread.status), comments: transformedComments, }, }; } catch (error) { if (error instanceof errors_1.AzureDevOpsError) { throw error; } throw new Error(`Failed to update pull request thread status: ${error instanceof Error ? error.message : String(error)}`); } } //# sourceMappingURL=feature.js.map