@smartbear/mcp 0.11.0 → 0.12.1

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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/bugsnag/client/api/Error.js +52 -14
  3. package/dist/bugsnag/client/api/Project.js +193 -8
  4. package/dist/bugsnag/client/api/api.js +130 -3
  5. package/dist/bugsnag/client/api/base.js +19 -0
  6. package/dist/bugsnag/client/api/index.js +1 -1
  7. package/dist/bugsnag/client.js +527 -20
  8. package/dist/bugsnag/input-schemas.js +14 -6
  9. package/dist/common/transport-stdio.js +5 -0
  10. package/dist/qmetry/client/auto-resolve.js +10 -0
  11. package/dist/qmetry/client/automation.js +171 -0
  12. package/dist/qmetry/client/handlers.js +9 -2
  13. package/dist/qmetry/client/project.js +87 -1
  14. package/dist/qmetry/client/testsuite.js +37 -1
  15. package/dist/qmetry/client/tools/automation-tools.js +290 -0
  16. package/dist/qmetry/client/tools/index.js +3 -0
  17. package/dist/qmetry/client/tools/issue-tools.js +1 -1
  18. package/dist/qmetry/client/tools/project-tools.js +311 -1
  19. package/dist/qmetry/client/tools/requirement-tools.js +1 -1
  20. package/dist/qmetry/client/tools/testcase-tools.js +311 -39
  21. package/dist/qmetry/client/tools/testsuite-tools.js +337 -23
  22. package/dist/qmetry/config/constants.js +6 -0
  23. package/dist/qmetry/config/rest-endpoints.js +8 -0
  24. package/dist/qmetry/types/automation.js +8 -0
  25. package/dist/qmetry/types/common.js +299 -4
  26. package/dist/qmetry/types/issues.js +5 -0
  27. package/dist/qmetry/types/project.js +13 -0
  28. package/dist/qmetry/types/requirements.js +5 -0
  29. package/dist/qmetry/types/testcase.js +5 -0
  30. package/dist/qmetry/types/testsuite.js +9 -0
  31. package/dist/swagger/client/api.js +93 -36
  32. package/dist/swagger/client/configuration.js +3 -1
  33. package/dist/swagger/client/portal-types.js +7 -6
  34. package/dist/swagger/client/registry-types.js +26 -0
  35. package/dist/swagger/client/tools.js +15 -16
  36. package/dist/swagger/client.js +6 -6
  37. package/dist/tests/unit/bugsnag/utils/factories.js +86 -0
  38. package/dist/zephyr/client.js +4 -0
  39. package/dist/zephyr/tool/environment/get-environments.js +68 -0
  40. package/dist/zephyr/tool/test-execution/get-test-executions.js +45 -0
  41. package/package.json +3 -2
@@ -3,25 +3,32 @@ const filterValueSchema = z.object({
3
3
  type: z.enum(["eq", "ne", "empty"]),
4
4
  value: z.union([z.string(), z.boolean(), z.number()]),
5
5
  });
6
+ const filtersSchema = z.record(z.array(filterValueSchema));
6
7
  /**
7
8
  * A collection of input parameter schemas for reuse between tools.
8
9
  * Add new entries when common parameters are identified.
9
10
  */
10
11
  export const toolInputParameters = {
11
12
  empty: z.object({}).describe("No parameters are required for this tool"),
13
+ buildId: z.string().describe("Unique identifier of the app build"),
14
+ errorId: z.string().describe("Unique identifier of the error"),
15
+ eventId: z.string().describe("Unique identifier of the event"),
12
16
  projectId: z
13
17
  .string()
14
18
  .optional()
15
- .describe("ID of the project. This is optional if a current project is set and is used to set the current project for BugSnag tools."),
16
- errorId: z.string().describe("Unique identifier of the error"),
17
- releaseId: z.string().describe("ID of the release"),
18
- buildId: z.string().describe("ID of the build"),
19
+ .describe("Unique identifier of the project. This is optional if a current project is set and is used to set the current project for BugSnag tools."),
20
+ releaseId: z.string().describe("Unique identifier of the app release"),
19
21
  direction: z
20
22
  .enum(["asc", "desc"])
21
23
  .describe("Sort direction for ordering results")
22
24
  .default("desc"),
23
- filters: z
24
- .record(z.array(filterValueSchema))
25
+ performanceFilters: filtersSchema
26
+ .describe("Apply filters to narrow down the span group list. Use the List Trace Fields tool to discover available filter fields. " +
27
+ "Time filters support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h).")
28
+ .default({
29
+ "span.since": [{ type: "eq", value: "7d" }],
30
+ }),
31
+ filters: filtersSchema
25
32
  .describe("Apply filters to narrow down the error list. Use the List Project Event Filters tool to discover available filter fields. " +
26
33
  "Time filters support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h).")
27
34
  .default({
@@ -48,4 +55,5 @@ export const toolInputParameters = {
48
55
  .enum(["first_seen", "last_seen", "events", "users", "unsorted"])
49
56
  .describe("Field to sort the errors by")
50
57
  .default("last_seen"),
58
+ spanGroupId: z.string().describe("ID of the span group"),
51
59
  };
@@ -1,5 +1,6 @@
1
1
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2
2
  import { clientRegistry } from "./client-registry.js";
3
+ import { MCP_SERVER_NAME, MCP_SERVER_VERSION } from "./info.js";
3
4
  import { SmartBearMcpServer } from "./server.js";
4
5
  /**
5
6
  * Generate a dynamic error message listing all available clients and their required env vars
@@ -22,6 +23,10 @@ function getNoConfigErrorMessage() {
22
23
  * Run server in STDIO mode (default)
23
24
  */
24
25
  export async function runStdioMode() {
26
+ if (process.argv.includes("--version")) {
27
+ console.log(`${MCP_SERVER_NAME}: v${MCP_SERVER_VERSION}`);
28
+ process.exit(0);
29
+ }
25
30
  const server = new SmartBearMcpServer();
26
31
  // Setup clients from environment variables
27
32
  const configuredCount = await clientRegistry.configure(server, (client, key) => {
@@ -25,6 +25,16 @@ export const AUTO_RESOLVE_MODULES = [
25
25
  viewIdPath: "latestViews.TS.viewId",
26
26
  moduleName: "Test Suites",
27
27
  },
28
+ {
29
+ handler: QMetryToolsHandlers.FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN,
30
+ viewIdPath: "latestViews.TE.viewId",
31
+ moduleName: "Test Case Run By Test Suite Run",
32
+ },
33
+ {
34
+ handler: QMetryToolsHandlers.FETCH_EXECUTIONS_BY_TESTSUITE,
35
+ viewIdPath: "latestViews.TEL.viewId",
36
+ moduleName: "Executions By Test Suites",
37
+ },
28
38
  {
29
39
  handler: QMetryToolsHandlers.FETCH_TESTSUITES_FOR_TESTCASE,
30
40
  viewIdPath: "latestViews.TSFS.viewId",
@@ -0,0 +1,171 @@
1
+ import { MCP_SERVER_NAME, MCP_SERVER_VERSION } from "../../common/info.js";
2
+ import { QMETRY_DEFAULTS } from "../config/constants.js";
3
+ import { QMETRY_PATHS } from "../config/rest-endpoints.js";
4
+ import { DEFAULT_IMPORT_AUTOMATION_PAYLOAD } from "../types/automation.js";
5
+ import { qmetryRequest } from "./api/client-api.js";
6
+ import { handleQMetryApiError } from "./api/error-handler.js";
7
+ /**
8
+ * Imports automation test results into QMetry
9
+ *
10
+ * This function handles file upload via FormData to import automation test results
11
+ * from various frameworks (TestNG, JUnit, Cucumber, Robot, etc.)
12
+ *
13
+ * CRITICAL NOTES:
14
+ * - User MUST provide a valid result file (.json, .xml, or .zip up to 30 MB)
15
+ * - File should be base64 encoded or provided as file path
16
+ * - EntityType is required and determines the framework format
17
+ * - Various parameters control test case/suite creation and linking behavior
18
+ *
19
+ * @param token - QMetry API authentication token
20
+ * @param baseUrl - QMetry instance base URL
21
+ * @param project - Project key (used in header, can be overridden by projectID in payload)
22
+ * @param payload - Import configuration including file data, entityType, and optional parameters
23
+ * @returns Promise resolving to import result with test suite and execution details
24
+ */
25
+ export async function importAutomationResults(token, baseUrl, project, payload) {
26
+ // Merge with defaults
27
+ const finalPayload = {
28
+ ...DEFAULT_IMPORT_AUTOMATION_PAYLOAD,
29
+ ...payload,
30
+ };
31
+ // Create FormData for multipart/form-data upload
32
+ const formData = new FormData();
33
+ // Handle file upload
34
+ // The file should be provided as base64 string or file content
35
+ let fileBlob;
36
+ if (finalPayload.file.startsWith("data:")) {
37
+ // Base64 data URI format
38
+ const base64Data = finalPayload.file.split(",")[1];
39
+ const binaryData = atob(base64Data);
40
+ const bytes = new Uint8Array(binaryData.length);
41
+ for (let i = 0; i < binaryData.length; i++) {
42
+ bytes[i] = binaryData.charCodeAt(i);
43
+ }
44
+ fileBlob = new Blob([bytes]);
45
+ }
46
+ else if (finalPayload.file.startsWith("/") ||
47
+ finalPayload.file.includes(":\\")) {
48
+ // File path - read file from filesystem (Node.js only)
49
+ try {
50
+ const fs = await import("node:fs/promises");
51
+ const fileBuffer = await fs.readFile(finalPayload.file);
52
+ fileBlob = new Blob([new Uint8Array(fileBuffer)]);
53
+ }
54
+ catch (error) {
55
+ throw new Error(`Failed to read file from path: ${finalPayload.file}. Error: ${error instanceof Error ? error.message : String(error)}`);
56
+ }
57
+ }
58
+ else {
59
+ // Assume raw base64 string
60
+ try {
61
+ const binaryData = atob(finalPayload.file);
62
+ const bytes = new Uint8Array(binaryData.length);
63
+ for (let i = 0; i < binaryData.length; i++) {
64
+ bytes[i] = binaryData.charCodeAt(i);
65
+ }
66
+ fileBlob = new Blob([bytes]);
67
+ }
68
+ catch (_error) {
69
+ throw new Error("Invalid file format. Please provide base64 encoded file content or file path.");
70
+ }
71
+ }
72
+ // Add file to FormData
73
+ formData.append("file", fileBlob, finalPayload.fileName);
74
+ // Add required entityType
75
+ formData.append("entityType", finalPayload.entityType);
76
+ // Add optional parameters
77
+ if (finalPayload.automationHierarchy) {
78
+ formData.append("automationHierarchy", finalPayload.automationHierarchy);
79
+ }
80
+ if (finalPayload.testsuiteName) {
81
+ formData.append("testsuiteName", finalPayload.testsuiteName);
82
+ }
83
+ if (finalPayload.testsuiteId) {
84
+ formData.append("testsuiteId", finalPayload.testsuiteId);
85
+ }
86
+ if (finalPayload.tsFolderPath) {
87
+ formData.append("tsFolderPath", finalPayload.tsFolderPath);
88
+ }
89
+ if (finalPayload.tcFolderPath) {
90
+ formData.append("tcFolderPath", finalPayload.tcFolderPath);
91
+ }
92
+ if (finalPayload.platformID) {
93
+ formData.append("platformID", finalPayload.platformID);
94
+ }
95
+ if (finalPayload.projectID) {
96
+ formData.append("projectID", finalPayload.projectID);
97
+ }
98
+ if (finalPayload.releaseID) {
99
+ formData.append("releaseID", finalPayload.releaseID);
100
+ }
101
+ if (finalPayload.cycleID) {
102
+ formData.append("cycleID", finalPayload.cycleID);
103
+ }
104
+ if (finalPayload.buildID) {
105
+ formData.append("buildID", finalPayload.buildID);
106
+ }
107
+ if (finalPayload.testcase_fields) {
108
+ formData.append("testcase_fields", finalPayload.testcase_fields);
109
+ }
110
+ if (finalPayload.testsuite_fields) {
111
+ formData.append("testsuite_fields", finalPayload.testsuite_fields);
112
+ }
113
+ if (finalPayload.skipWarning) {
114
+ formData.append("skipWarning", finalPayload.skipWarning);
115
+ }
116
+ if (finalPayload.is_matching_required) {
117
+ formData.append("is_matching_required", finalPayload.is_matching_required);
118
+ }
119
+ // Make API request
120
+ const url = `${baseUrl || QMETRY_DEFAULTS.BASE_URL}${QMETRY_PATHS.AUTOMATION.IMPORT_RESULTS}`;
121
+ const headers = {
122
+ apikey: token,
123
+ project: finalPayload.projectID || project || QMETRY_DEFAULTS.PROJECT_KEY,
124
+ "User-Agent": `${MCP_SERVER_NAME}/${MCP_SERVER_VERSION}`,
125
+ // Note: Content-Type will be set automatically by fetch for FormData
126
+ };
127
+ let res;
128
+ try {
129
+ res = await fetch(url, {
130
+ method: "POST",
131
+ headers,
132
+ body: formData,
133
+ });
134
+ }
135
+ catch (error) {
136
+ throw new Error(`Failed to import automation results. Network error: ${error instanceof Error ? error.message : String(error)}\n\nPlease check:\n- QMetry server is accessible\n- File size is under 30 MB\n- File format is .json, .xml, or .zip`);
137
+ }
138
+ if (!res.ok) {
139
+ await handleQMetryApiError(res, baseUrl || QMETRY_DEFAULTS.BASE_URL, project || QMETRY_DEFAULTS.PROJECT_KEY, QMETRY_PATHS.AUTOMATION.IMPORT_RESULTS);
140
+ }
141
+ return await res.json();
142
+ }
143
+ /**
144
+ * Fetches automation status by request ID from QMetry
145
+ * @param token - QMetry API authentication token
146
+ * @param baseUrl - QMetry instance base URL
147
+ * @param requestID - Numeric request ID from import automation response
148
+ * @returns Promise resolving to automation status
149
+ */
150
+ export async function getAutomationStatus(token, baseUrl, project, requestID) {
151
+ let numericRequestID;
152
+ if (typeof requestID === "object" &&
153
+ requestID !== null &&
154
+ "requestID" in requestID &&
155
+ typeof requestID.requestID !== "undefined") {
156
+ numericRequestID = Number(requestID.requestID);
157
+ }
158
+ else {
159
+ numericRequestID = Number(requestID);
160
+ }
161
+ if (!numericRequestID || Number.isNaN(numericRequestID)) {
162
+ throw new Error("requestID must be a valid number");
163
+ }
164
+ return qmetryRequest({
165
+ method: "GET",
166
+ path: QMETRY_PATHS.AUTOMATION.GET_STATUS.replace(":requestID", String(numericRequestID)),
167
+ token,
168
+ baseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
169
+ project: project || QMETRY_DEFAULTS.PROJECT_KEY,
170
+ });
171
+ }
@@ -1,9 +1,10 @@
1
1
  import { QMetryToolsHandlers } from "../config/constants.js";
2
+ import { getAutomationStatus, importAutomationResults } from "./automation.js";
2
3
  import { createIssue, fetchIssues, fetchIssuesLinkedToTestCase, linkIssuesToTestcaseRun, updateIssue, } from "./issues.js";
3
- import { getBuilds, getPlatforms, getProjectInfo, getProjects, getReleasesCycles, } from "./project.js";
4
+ import { createCycle, createRelease, getBuilds, getPlatforms, getProjectInfo, getProjects, getReleasesCycles, updateCycle, } from "./project.js";
4
5
  import { fetchRequirementDetails, fetchRequirements, fetchRequirementsLinkedToTestCase, } from "./requirement.js";
5
6
  import { createTestCases, fetchTestCaseDetails, fetchTestCaseExecutions, fetchTestCaseSteps, fetchTestCases, fetchTestCasesLinkedToRequirement, fetchTestCaseVersionDetails, linkRequirementToTestCase, updateTestCase, } from "./testcase.js";
6
- import { createTestSuites, fetchExecutionsByTestSuite, fetchLinkedIssuesByTestCaseRun, fetchTestCaseRunsByTestSuiteRun, fetchTestCasesByTestSuite, fetchTestSuites, fetchTestSuitesForTestCase, linkPlatformsToTestSuite, linkTestCasesToTestSuite, reqLinkedTestCasesToTestSuite, updateTestSuite, } from "./testsuite.js";
7
+ import { bulkUpdateExecutionStatus, createTestSuites, fetchExecutionsByTestSuite, fetchLinkedIssuesByTestCaseRun, fetchTestCaseRunsByTestSuiteRun, fetchTestCasesByTestSuite, fetchTestSuites, fetchTestSuitesForTestCase, linkPlatformsToTestSuite, linkTestCasesToTestSuite, reqLinkedTestCasesToTestSuite, updateTestSuite, } from "./testsuite.js";
7
8
  export const QMETRY_HANDLER_MAP = {
8
9
  [QMetryToolsHandlers.FETCH_PROJECTS]: getProjects,
9
10
  [QMetryToolsHandlers.SET_PROJECT_INFO]: getProjectInfo,
@@ -11,6 +12,9 @@ export const QMETRY_HANDLER_MAP = {
11
12
  [QMetryToolsHandlers.FETCH_RELEASES_CYCLES]: getReleasesCycles,
12
13
  [QMetryToolsHandlers.FETCH_BUILDS]: getBuilds,
13
14
  [QMetryToolsHandlers.FETCH_PLATFORMS]: getPlatforms,
15
+ [QMetryToolsHandlers.CREATE_RELEASE]: createRelease,
16
+ [QMetryToolsHandlers.CREATE_CYCLE]: createCycle,
17
+ [QMetryToolsHandlers.UPDATE_CYCLE]: updateCycle,
14
18
  [QMetryToolsHandlers.CREATE_TEST_CASE]: createTestCases,
15
19
  [QMetryToolsHandlers.UPDATE_TEST_CASE]: updateTestCase,
16
20
  [QMetryToolsHandlers.FETCH_TEST_CASES]: fetchTestCases,
@@ -31,6 +35,7 @@ export const QMETRY_HANDLER_MAP = {
31
35
  [QMetryToolsHandlers.REQUIREMENTS_LINKED_TESTCASES_TO_TESTSUITE]: reqLinkedTestCasesToTestSuite,
32
36
  [QMetryToolsHandlers.FETCH_TESTCASES_BY_TESTSUITE]: fetchTestCasesByTestSuite,
33
37
  [QMetryToolsHandlers.FETCH_EXECUTIONS_BY_TESTSUITE]: fetchExecutionsByTestSuite,
38
+ [QMetryToolsHandlers.BULK_UPDATE_EXECUTION_STATUS]: bulkUpdateExecutionStatus,
34
39
  [QMetryToolsHandlers.FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN]: fetchTestCaseRunsByTestSuiteRun,
35
40
  [QMetryToolsHandlers.FETCH_LINKED_ISSUES_BY_TESTCASE_RUN]: fetchLinkedIssuesByTestCaseRun,
36
41
  [QMetryToolsHandlers.FETCH_ISSUES_LINKED_TO_TESTCASE]: fetchIssuesLinkedToTestCase,
@@ -39,4 +44,6 @@ export const QMETRY_HANDLER_MAP = {
39
44
  [QMetryToolsHandlers.FETCH_ISSUES]: fetchIssues,
40
45
  [QMetryToolsHandlers.LINK_ISSUES_TO_TESTCASE_RUN]: linkIssuesToTestcaseRun,
41
46
  [QMetryToolsHandlers.LINK_PLATFORMS_TO_TESTSUITE]: linkPlatformsToTestSuite,
47
+ [QMetryToolsHandlers.IMPORT_AUTOMATION_RESULTS]: importAutomationResults,
48
+ [QMetryToolsHandlers.FETCH_AUTOMATION_STATUS]: getAutomationStatus,
42
49
  };
@@ -1,7 +1,8 @@
1
1
  import { QMETRY_DEFAULTS } from "../config/constants.js";
2
2
  import { QMETRY_PATHS } from "../config/rest-endpoints.js";
3
- import { DEFAULT_FETCH_BUILD_PAYLOAD, DEFAULT_FETCH_PLATFORMS_PAYLOAD, DEFAULT_FETCH_PROJECTS_PAYLOAD, } from "../types/project.js";
3
+ import { DEFAULT_CREATE_CYCLE_PAYLOAD, DEFAULT_CREATE_RELEASE_PAYLOAD, DEFAULT_FETCH_BUILD_PAYLOAD, DEFAULT_FETCH_PLATFORMS_PAYLOAD, DEFAULT_FETCH_PROJECTS_PAYLOAD, } from "../types/project.js";
4
4
  import { qmetryRequest } from "./api/client-api.js";
5
+ import { resolveDefaults } from "./utils.js";
5
6
  /**
6
7
  * Retrieves project information from QMetry
7
8
  *
@@ -98,3 +99,88 @@ export async function getPlatforms(token, baseUrl, project, payload) {
98
99
  body,
99
100
  });
100
101
  }
102
+ /**
103
+ * Creates a new release in QMetry with optional cycle
104
+ *
105
+ * @param token - QMetry API authentication token
106
+ * @param baseUrl - QMetry instance base URL
107
+ * @param project - Project key
108
+ * @param payload - Release and cycle data
109
+ * @returns Promise resolving to the created release information
110
+ */
111
+ export async function createRelease(token, baseUrl, project, payload) {
112
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
113
+ const body = {
114
+ ...DEFAULT_CREATE_RELEASE_PAYLOAD,
115
+ ...payload,
116
+ };
117
+ if (typeof body.release.name !== "string") {
118
+ throw new Error("[createRelease] Missing or invalid required parameter: 'release.name'.");
119
+ }
120
+ if (body.cycle && typeof body.cycle.name !== "string") {
121
+ throw new Error("[createRelease] Missing or invalid required parameter: 'cycle.name'.");
122
+ }
123
+ return qmetryRequest({
124
+ method: "POST",
125
+ path: QMETRY_PATHS.PROJECT.CREATE_RELEASE,
126
+ token,
127
+ project: resolvedProject,
128
+ baseUrl: resolvedBaseUrl,
129
+ body,
130
+ });
131
+ }
132
+ /**
133
+ * Creates a new cycle within an existing release in QMetry
134
+ *
135
+ * @param token - QMetry API authentication token
136
+ * @param baseUrl - QMetry instance base URL
137
+ * @param project - Project key
138
+ * @param payload - Cycle data including releaseID
139
+ * @returns Promise resolving to the created cycle information
140
+ */
141
+ export async function createCycle(token, baseUrl, project, payload) {
142
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
143
+ const body = {
144
+ ...DEFAULT_CREATE_CYCLE_PAYLOAD.cycle,
145
+ ...payload,
146
+ };
147
+ if (typeof body.cycle.name !== "string") {
148
+ throw new Error("[createCycle] Missing or invalid required parameter: 'cycle.name'.");
149
+ }
150
+ if (typeof body.cycle.releaseID !== "number") {
151
+ throw new Error("[createCycle] Missing or invalid required parameter: 'cycle.releaseID'.");
152
+ }
153
+ return qmetryRequest({
154
+ method: "POST",
155
+ path: QMETRY_PATHS.PROJECT.CREATE_CYCLE,
156
+ token,
157
+ project: resolvedProject,
158
+ baseUrl: resolvedBaseUrl,
159
+ body,
160
+ });
161
+ }
162
+ /**
163
+ * Updates an existing cycle in QMetry
164
+ * @param token - QMetry API token
165
+ * @param baseUrl - QMetry base URL
166
+ * @param project - Project key
167
+ * @param payload - Cycle data including buildID and releaseID for identification
168
+ * @returns Promise resolving to the updated cycle information
169
+ */
170
+ export async function updateCycle(token, baseUrl, project, payload) {
171
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
172
+ if (typeof payload.cycle.buildID !== "number") {
173
+ throw new Error("[updateCycle] Missing or invalid required parameter: 'cycle.buildID'.");
174
+ }
175
+ if (typeof payload.cycle.releaseID !== "number") {
176
+ throw new Error("[updateCycle] Missing or invalid required parameter: 'cycle.releaseID'.");
177
+ }
178
+ return qmetryRequest({
179
+ method: "PUT",
180
+ path: QMETRY_PATHS.PROJECT.UPDATE_CYCLE,
181
+ token,
182
+ project: resolvedProject,
183
+ baseUrl: resolvedBaseUrl,
184
+ body: payload,
185
+ });
186
+ }
@@ -1,5 +1,5 @@
1
1
  import { QMETRY_PATHS } from "../config/rest-endpoints.js";
2
- import { DEFAULT_CREATE_TESTSUITE_PAYLOAD, DEFAULT_FETCH_EXECUTIONS_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_LINKED_ISSUES_BY_TESTCASE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASES_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_FOR_TESTCASE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_PAYLOAD, DEFAULT_LINKED_PLATFORMS_TO_TESTSUITE_PAYLOAD, DEFAULT_LINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_REQLINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_UPDATE_TESTSUITE_PAYLOAD, } from "../types/testsuite.js";
2
+ import { DEFAULT_BULK_UPDATE_EXECUTION_STATUS_PAYLOAD, DEFAULT_CREATE_TESTSUITE_PAYLOAD, DEFAULT_FETCH_EXECUTIONS_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_LINKED_ISSUES_BY_TESTCASE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASES_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_FOR_TESTCASE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_PAYLOAD, DEFAULT_LINKED_PLATFORMS_TO_TESTSUITE_PAYLOAD, DEFAULT_LINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_REQLINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_UPDATE_TESTSUITE_PAYLOAD, } from "../types/testsuite.js";
3
3
  import { qmetryRequest } from "./api/client-api.js";
4
4
  import { resolveDefaults } from "./utils.js";
5
5
  /**
@@ -270,3 +270,39 @@ export async function linkPlatformsToTestSuite(token, baseUrl, project, payload)
270
270
  body,
271
271
  });
272
272
  }
273
+ /**
274
+ * Bulk update execution status for test case runs.
275
+ * @throws If `entityIDs`, `entityType`, `qmTsRunId`, or `runStatusID` are missing/invalid.
276
+ */
277
+ export async function bulkUpdateExecutionStatus(token, baseUrl, project, payload) {
278
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
279
+ const body = {
280
+ ...DEFAULT_BULK_UPDATE_EXECUTION_STATUS_PAYLOAD,
281
+ ...payload,
282
+ };
283
+ if (!body.entityIDs ||
284
+ typeof body.entityIDs !== "string" ||
285
+ body.entityIDs.trim().length === 0) {
286
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'entityIDs'. It must be a non-empty comma-separated string of Test Case Run IDs.");
287
+ }
288
+ if (!body.entityType ||
289
+ (body.entityType !== "TCR" && body.entityType !== "TCSR")) {
290
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'entityType'. Must be 'TCR' or 'TCSR'.");
291
+ }
292
+ if (!body.qmTsRunId ||
293
+ typeof body.qmTsRunId !== "string" ||
294
+ body.qmTsRunId.trim().length === 0) {
295
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'qmTsRunId'. It must be a non-empty string.");
296
+ }
297
+ if (typeof body.runStatusID !== "number") {
298
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'runStatusID'. It must be a number.");
299
+ }
300
+ return qmetryRequest({
301
+ method: "PUT",
302
+ path: QMETRY_PATHS.TESTSUITE.BULK_UPDATE_EXECUTION_STATUS,
303
+ token,
304
+ project: resolvedProject,
305
+ baseUrl: resolvedBaseUrl,
306
+ body,
307
+ });
308
+ }