UNPKG

@smartbear/mcp

Version:

MCP server for interacting SmartBear Products

77 lines (76 loc) 2.86 kB
import { QMETRY_PATHS } from "../config/rest-endpoints.js"; import { DEFAULT_FETCH_REQUIREMENT_DETAILS_PAYLOAD, DEFAULT_FETCH_REQUIREMENTS_LINKED_TO_TESTCASE_PAYLOAD, DEFAULT_FETCH_REQUIREMENTS_PAYLOAD, } from "../types/requirements.js"; import { qmetryRequest } from "./api/client-api.js"; import { resolveDefaults } from "./utils.js"; /** * Fetches a list of requirements. * @throws If `viewId` or `folderPath` are missing/invalid. */ export async function fetchRequirements(token, baseUrl, project, payload) { const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project); const body = { ...DEFAULT_FETCH_REQUIREMENTS_PAYLOAD, ...payload, }; if (typeof body.viewId !== "number") { throw new Error("[fetchRequirements] Missing or invalid required parameter: 'viewId'."); } if (typeof body.folderPath !== "string") { throw new Error("[fetchRequirements] Missing or invalid required parameter: 'folderPath'."); } return qmetryRequest({ method: "POST", path: QMETRY_PATHS.REQUIREMENT.GET_RQ_LIST, token, project: resolvedProject, baseUrl: resolvedBaseUrl, body, }); } /** * Fetches requirement details by numeric ID. * @throws If `id` or `version` are missing/invalid. */ export async function fetchRequirementDetails(token, baseUrl, project, payload) { const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project); const body = { ...DEFAULT_FETCH_REQUIREMENT_DETAILS_PAYLOAD, ...payload, }; if (typeof body.id !== "number") { throw new Error("[fetchRequirementDetails] Missing or invalid required parameter: 'id'."); } if (typeof body.version !== "number") { throw new Error("[fetchRequirementDetails] Missing or invalid required parameter: 'version'."); } return qmetryRequest({ method: "POST", path: QMETRY_PATHS.REQUIREMENT.GET_RQ_DETAILS, token, project: resolvedProject, baseUrl: resolvedBaseUrl, body, }); } /** * Fetches requirements linked to a specific test case. * @throws If `tcID` is missing/invalid. */ export async function fetchRequirementsLinkedToTestCase(token, baseUrl, project, payload) { const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project); const body = { ...DEFAULT_FETCH_REQUIREMENTS_LINKED_TO_TESTCASE_PAYLOAD, ...payload, }; if (typeof body.tcID !== "number") { throw new Error("[fetchRequirementsLinkedToTestCase] Missing or invalid required parameter: 'tcID'."); } return qmetryRequest({ method: "POST", path: QMETRY_PATHS.REQUIREMENT.GET_RQ_LINKED_TO_TC, token, project: resolvedProject, baseUrl: resolvedBaseUrl, body, }); }