UNPKG

deepsource-mcp-server

Version:
59 lines 2.24 kB
/** * @fileoverview GraphQL response processors * This module provides utilities for processing GraphQL responses. */ /** * Process issues from run checks in a GraphQL response * @param response The raw GraphQL response * @returns Processed issues with pagination information * @public */ export function processRunChecksResponse(response) { const issues = []; let pageInfo = { hasNextPage: false, hasPreviousPage: false, startCursor: undefined, endCursor: undefined, }; let totalCount = 0; const checks = response.data.data?.run?.checks?.edges ?? []; for (const { node: check } of checks) { const occurrences = check.occurrences?.edges ?? []; const occurrencesPageInfo = check.occurrences?.pageInfo; const occurrencesTotalCount = check.occurrences?.totalCount ?? 0; // Aggregate page info (using the first check's pagination info for simplicity) if (occurrencesPageInfo) { pageInfo = occurrencesPageInfo; totalCount += occurrencesTotalCount; } for (const { node: occurrence } of occurrences) { if (!occurrence || !occurrence.issue) continue; issues.push({ id: occurrence.id ?? 'unknown', shortcode: occurrence.issue.shortcode ?? '', title: occurrence.issue.title ?? 'Untitled Issue', category: occurrence.issue.category ?? 'UNKNOWN', severity: occurrence.issue.severity ?? 'UNKNOWN', status: 'OPEN', issue_text: occurrence.issue.description ?? '', file_path: occurrence.path ?? 'N/A', line_number: occurrence.beginLine ?? 0, tags: occurrence.issue.tags ?? [], }); } } return { issues, pageInfo, totalCount }; } /** * Extract error messages from GraphQL error response * @param errors Array of GraphQL error objects * @returns Formatted error message string * @public */ export function extractGraphQLErrorMessages(errors) { const errorMessages = errors.map((error) => error.message); return errorMessages.join(', '); } //# sourceMappingURL=processor.js.map