@smartbear/mcp 0.8.0 → 0.10.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.
Files changed (66) hide show
  1. package/README.md +29 -4
  2. package/dist/api-hub/client/api.js +239 -10
  3. package/dist/api-hub/client/configuration.js +5 -0
  4. package/dist/api-hub/client/index.js +1 -0
  5. package/dist/api-hub/client/portal-types.js +126 -0
  6. package/dist/api-hub/client/registry-types.js +8 -0
  7. package/dist/api-hub/client/tools.js +78 -15
  8. package/dist/api-hub/client/user-management-types.js +24 -0
  9. package/dist/api-hub/client.js +34 -0
  10. package/dist/bugsnag/client/api/CurrentUser.js +12 -49
  11. package/dist/bugsnag/client/api/Error.js +29 -142
  12. package/dist/bugsnag/client/api/Project.js +52 -113
  13. package/dist/bugsnag/client/api/api.js +3743 -0
  14. package/dist/bugsnag/client/api/base.js +97 -34
  15. package/dist/bugsnag/client/api/configuration.js +26 -0
  16. package/dist/bugsnag/client/api/index.js +2 -0
  17. package/dist/bugsnag/client/filters.js +28 -0
  18. package/dist/bugsnag/client.js +104 -155
  19. package/dist/collaborator/client.js +364 -0
  20. package/dist/common/server.js +73 -23
  21. package/dist/common/types.js +6 -1
  22. package/dist/index.js +9 -1
  23. package/dist/pactflow/client/prompt-utils.js +2 -1
  24. package/dist/pactflow/client/tools.js +4 -4
  25. package/dist/pactflow/client/utils.js +5 -4
  26. package/dist/pactflow/client.js +10 -9
  27. package/dist/qmetry/client/api/client-api.js +21 -16
  28. package/dist/qmetry/client/api/error-handler.js +329 -0
  29. package/dist/qmetry/client/auto-resolve.js +96 -0
  30. package/dist/qmetry/client/handlers.js +33 -2
  31. package/dist/qmetry/client/issues.js +123 -0
  32. package/dist/qmetry/client/project.js +73 -0
  33. package/dist/qmetry/client/requirement.js +76 -0
  34. package/dist/qmetry/client/testcase.js +122 -6
  35. package/dist/qmetry/client/testsuite.js +272 -0
  36. package/dist/qmetry/client/tools/index.js +17 -0
  37. package/dist/qmetry/client/tools/issue-tools.js +545 -0
  38. package/dist/qmetry/client/tools/project-tools.js +348 -0
  39. package/dist/qmetry/client/tools/requirement-tools.js +530 -0
  40. package/dist/qmetry/client/tools/testcase-tools.js +526 -0
  41. package/dist/qmetry/client/tools/testsuite-tools.js +772 -0
  42. package/dist/qmetry/client/tools/types.js +1 -0
  43. package/dist/qmetry/client/utils.js +16 -0
  44. package/dist/qmetry/client.js +27 -17
  45. package/dist/qmetry/config/constants.js +28 -0
  46. package/dist/qmetry/config/rest-endpoints.js +30 -0
  47. package/dist/qmetry/types/common.js +599 -9
  48. package/dist/qmetry/types/issues.js +16 -0
  49. package/dist/qmetry/types/project.js +17 -0
  50. package/dist/qmetry/types/requirements.js +19 -0
  51. package/dist/qmetry/types/testcase.js +20 -0
  52. package/dist/qmetry/types/testsuite.js +44 -0
  53. package/dist/reflect/client.js +7 -6
  54. package/dist/zephyr/client.js +7 -1
  55. package/dist/zephyr/common/api-client.js +8 -0
  56. package/dist/zephyr/common/auth-service.js +1 -0
  57. package/dist/zephyr/common/rest-api-schemas.js +5173 -0
  58. package/dist/zephyr/tool/project/get-project.js +39 -0
  59. package/dist/zephyr/tool/project/get-projects.js +7 -13
  60. package/dist/zephyr/tool/test-cycle/get-test-cycles.js +72 -0
  61. package/package.json +1 -1
  62. package/dist/bugsnag/client/api/filters.js +0 -167
  63. package/dist/bugsnag/client/configuration.js +0 -10
  64. package/dist/bugsnag/client/index.js +0 -2
  65. package/dist/qmetry/client/tools.js +0 -222
  66. package/dist/zephyr/common/types.js +0 -35
@@ -0,0 +1,123 @@
1
+ import { QMETRY_PATHS } from "../config/rest-endpoints.js";
2
+ import { DEFAULT_CREATE_ISSUE_PAYLOAD, DEFAULT_FETCH_ISSUES_LINKED_TO_TESTCASE_PAYLOAD, DEFAULT_FETCH_ISSUES_PAYLOAD, DEFAULT_LINK_ISSUES_TO_TESTCASE_RUN_PAYLOAD, DEFAULT_UPDATE_ISSUE_PAYLOAD, } from "../types/issues.js";
3
+ import { qmetryRequest } from "./api/client-api.js";
4
+ import { resolveDefaults } from "./utils.js";
5
+ /**
6
+ * Create Defect/Issue.
7
+ * @throws If `issueType` or `issuePriority` or `summary` are missing/invalid.
8
+ */
9
+ export async function createIssue(token, baseUrl, project, payload) {
10
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
11
+ const body = {
12
+ ...DEFAULT_CREATE_ISSUE_PAYLOAD,
13
+ ...payload,
14
+ };
15
+ if (typeof body.issueType !== "number") {
16
+ throw new Error("[createIssue] Missing or invalid required parameter: 'issueType'.");
17
+ }
18
+ if (typeof body.issuePriority !== "number") {
19
+ throw new Error("[createIssue] Missing or invalid required parameter: 'issuePriority'.");
20
+ }
21
+ if (typeof body.summary !== "string") {
22
+ throw new Error("[createIssue] Missing or invalid required parameter: 'summary'.");
23
+ }
24
+ return qmetryRequest({
25
+ method: "POST",
26
+ path: QMETRY_PATHS.ISSUES.CREATE_UPDATE_ISSUE,
27
+ token,
28
+ project: resolvedProject,
29
+ baseUrl: resolvedBaseUrl,
30
+ body,
31
+ });
32
+ }
33
+ /**
34
+ * Update Defect/Issue.
35
+ * @throws If `DefectId` is missing/invalid.
36
+ */
37
+ export async function updateIssue(token, baseUrl, project, payload) {
38
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
39
+ const body = {
40
+ ...DEFAULT_UPDATE_ISSUE_PAYLOAD,
41
+ ...payload,
42
+ };
43
+ if (typeof body.DefectId !== "number") {
44
+ throw new Error("[updateIssue] Missing or invalid required parameter: 'DefectId'.");
45
+ }
46
+ return qmetryRequest({
47
+ method: "PUT",
48
+ path: QMETRY_PATHS.ISSUES.CREATE_UPDATE_ISSUE,
49
+ token,
50
+ project: resolvedProject,
51
+ baseUrl: resolvedBaseUrl,
52
+ body,
53
+ });
54
+ }
55
+ /**
56
+ * Fetches a list of test suites.
57
+ * @throws If `viewId` or `folderPath` are missing/invalid.
58
+ */
59
+ export async function fetchIssues(token, baseUrl, project, payload) {
60
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
61
+ const body = {
62
+ ...DEFAULT_FETCH_ISSUES_PAYLOAD,
63
+ ...payload,
64
+ };
65
+ if (typeof body.viewId !== "number") {
66
+ throw new Error("[fetchIssues] Missing or invalid required parameter: 'viewId'.");
67
+ }
68
+ return qmetryRequest({
69
+ method: "POST",
70
+ path: QMETRY_PATHS.ISSUES.GET_ISSUES_LIST,
71
+ token,
72
+ project: resolvedProject,
73
+ baseUrl: resolvedBaseUrl,
74
+ body,
75
+ });
76
+ }
77
+ /**
78
+ * Fetches issues linked to a specific test case.
79
+ * @throws If `tcID` is missing/invalid.
80
+ */
81
+ export async function fetchIssuesLinkedToTestCase(token, baseUrl, project, payload) {
82
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
83
+ const body = {
84
+ ...DEFAULT_FETCH_ISSUES_LINKED_TO_TESTCASE_PAYLOAD,
85
+ ...payload,
86
+ };
87
+ if (typeof body.tcID !== "number") {
88
+ throw new Error("[fetchIssuesLinkedToTestCase] Missing or invalid required parameter: 'tcID'.");
89
+ }
90
+ return qmetryRequest({
91
+ method: "POST",
92
+ path: QMETRY_PATHS.ISSUES.GET_ISSUES_LINKED_TO_TC,
93
+ token,
94
+ project: resolvedProject,
95
+ baseUrl: resolvedBaseUrl,
96
+ body,
97
+ });
98
+ }
99
+ /**
100
+ * Link Issues to Testcase Run.
101
+ * @throws If issueIds or tcrId are missing/invalid.
102
+ */
103
+ export async function linkIssuesToTestcaseRun(token, baseUrl, project, payload) {
104
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
105
+ const body = {
106
+ ...DEFAULT_LINK_ISSUES_TO_TESTCASE_RUN_PAYLOAD,
107
+ ...payload,
108
+ };
109
+ if (!Array.isArray(body.issueIds) || body.issueIds.length === 0) {
110
+ throw new Error("[linkIssuesToTestcaseRun] Missing or invalid required parameter: 'issueIds'.");
111
+ }
112
+ if (typeof body.tcrId !== "number") {
113
+ throw new Error("[linkIssuesToTestcaseRun] Missing or invalid required parameter: 'tcrId'.");
114
+ }
115
+ return qmetryRequest({
116
+ method: "PUT",
117
+ path: QMETRY_PATHS.ISSUES.LINK_ISSUES_TO_TESTCASE_RUN,
118
+ token,
119
+ project: resolvedProject,
120
+ baseUrl: resolvedBaseUrl,
121
+ body,
122
+ });
123
+ }
@@ -1,5 +1,6 @@
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
4
  import { qmetryRequest } from "./api/client-api.js";
4
5
  /**
5
6
  * Retrieves project information from QMetry
@@ -25,3 +26,75 @@ export async function getProjectInfo(token, baseUrl, project) {
25
26
  project: project || QMETRY_DEFAULTS.PROJECT_KEY,
26
27
  });
27
28
  }
29
+ /**
30
+ * Fetches a List of projects.
31
+ */
32
+ export async function getProjects(token, baseUrl, project, payload) {
33
+ const body = {
34
+ ...DEFAULT_FETCH_PROJECTS_PAYLOAD,
35
+ ...payload,
36
+ };
37
+ return qmetryRequest({
38
+ method: "POST",
39
+ path: QMETRY_PATHS.PROJECT.GET_PROJECTS,
40
+ token,
41
+ baseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
42
+ project: project || QMETRY_DEFAULTS.PROJECT_KEY,
43
+ body,
44
+ });
45
+ }
46
+ export async function getReleasesCycles(token, baseUrl, project, payload = {}) {
47
+ let showArchiveValue;
48
+ if (payload.showArchive !== undefined) {
49
+ showArchiveValue = payload.showArchive;
50
+ }
51
+ else {
52
+ showArchiveValue = false;
53
+ }
54
+ const body = {
55
+ showArchive: showArchiveValue,
56
+ };
57
+ return qmetryRequest({
58
+ method: "POST",
59
+ path: QMETRY_PATHS.PROJECT.GET_RELEASES_CYCLES,
60
+ token,
61
+ baseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
62
+ project: project || QMETRY_DEFAULTS.PROJECT_KEY,
63
+ body,
64
+ });
65
+ }
66
+ /**
67
+ * Fetches a List of Builds of the current project.
68
+ */
69
+ export async function getBuilds(token, baseUrl, project, payload) {
70
+ const body = {
71
+ ...DEFAULT_FETCH_BUILD_PAYLOAD,
72
+ ...payload,
73
+ };
74
+ return qmetryRequest({
75
+ method: "POST",
76
+ path: QMETRY_PATHS.PROJECT.GET_BUILD,
77
+ token,
78
+ baseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
79
+ project: project || QMETRY_DEFAULTS.PROJECT_KEY,
80
+ body,
81
+ });
82
+ }
83
+ /**
84
+ * Fetches platforms from the current QMetry project
85
+ *
86
+ */
87
+ export async function getPlatforms(token, baseUrl, project, payload) {
88
+ const body = {
89
+ ...DEFAULT_FETCH_PLATFORMS_PAYLOAD,
90
+ ...payload,
91
+ };
92
+ return qmetryRequest({
93
+ method: "POST",
94
+ path: QMETRY_PATHS.PROJECT.GET_PLATFORMS,
95
+ token,
96
+ baseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
97
+ project: project || QMETRY_DEFAULTS.PROJECT_KEY,
98
+ body,
99
+ });
100
+ }
@@ -0,0 +1,76 @@
1
+ import { QMETRY_PATHS } from "../config/rest-endpoints.js";
2
+ import { DEFAULT_FETCH_REQUIREMENT_DETAILS_PAYLOAD, DEFAULT_FETCH_REQUIREMENTS_LINKED_TO_TESTCASE_PAYLOAD, DEFAULT_FETCH_REQUIREMENTS_PAYLOAD, } from "../types/requirements.js";
3
+ import { qmetryRequest } from "./api/client-api.js";
4
+ import { resolveDefaults } from "./utils.js";
5
+ /**
6
+ * Fetches a list of requirements.
7
+ * @throws If `viewId` or `folderPath` are missing/invalid.
8
+ */
9
+ export async function fetchRequirements(token, baseUrl, project, payload) {
10
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
11
+ const body = {
12
+ ...DEFAULT_FETCH_REQUIREMENTS_PAYLOAD,
13
+ ...payload,
14
+ };
15
+ if (typeof body.viewId !== "number") {
16
+ throw new Error("[fetchRequirements] Missing or invalid required parameter: 'viewId'.");
17
+ }
18
+ if (typeof body.folderPath !== "string") {
19
+ throw new Error("[fetchRequirements] Missing or invalid required parameter: 'folderPath'.");
20
+ }
21
+ return qmetryRequest({
22
+ method: "POST",
23
+ path: QMETRY_PATHS.REQUIREMENT.GET_RQ_LIST,
24
+ token,
25
+ project: resolvedProject,
26
+ baseUrl: resolvedBaseUrl,
27
+ body,
28
+ });
29
+ }
30
+ /**
31
+ * Fetches requirement details by numeric ID.
32
+ * @throws If `id` or `version` are missing/invalid.
33
+ */
34
+ export async function fetchRequirementDetails(token, baseUrl, project, payload) {
35
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
36
+ const body = {
37
+ ...DEFAULT_FETCH_REQUIREMENT_DETAILS_PAYLOAD,
38
+ ...payload,
39
+ };
40
+ if (typeof body.id !== "number") {
41
+ throw new Error("[fetchRequirementDetails] Missing or invalid required parameter: 'id'.");
42
+ }
43
+ if (typeof body.version !== "number") {
44
+ throw new Error("[fetchRequirementDetails] Missing or invalid required parameter: 'version'.");
45
+ }
46
+ return qmetryRequest({
47
+ method: "POST",
48
+ path: QMETRY_PATHS.REQUIREMENT.GET_RQ_DETAILS,
49
+ token,
50
+ project: resolvedProject,
51
+ baseUrl: resolvedBaseUrl,
52
+ body,
53
+ });
54
+ }
55
+ /**
56
+ * Fetches requirements linked to a specific test case.
57
+ * @throws If `tcID` is missing/invalid.
58
+ */
59
+ export async function fetchRequirementsLinkedToTestCase(token, baseUrl, project, payload) {
60
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
61
+ const body = {
62
+ ...DEFAULT_FETCH_REQUIREMENTS_LINKED_TO_TESTCASE_PAYLOAD,
63
+ ...payload,
64
+ };
65
+ if (typeof body.tcID !== "number") {
66
+ throw new Error("[fetchRequirementsLinkedToTestCase] Missing or invalid required parameter: 'tcID'.");
67
+ }
68
+ return qmetryRequest({
69
+ method: "POST",
70
+ path: QMETRY_PATHS.REQUIREMENT.GET_RQ_LINKED_TO_TC,
71
+ token,
72
+ project: resolvedProject,
73
+ baseUrl: resolvedBaseUrl,
74
+ body,
75
+ });
76
+ }
@@ -1,12 +1,56 @@
1
- import { QMETRY_DEFAULTS } from "../config/constants.js";
2
1
  import { QMETRY_PATHS } from "../config/rest-endpoints.js";
3
- import { DEFAULT_FETCH_TESTCASE_DETAILS_PAYLOAD, DEFAULT_FETCH_TESTCASE_STEPS_PAYLOAD, DEFAULT_FETCH_TESTCASE_VERSION_DETAILS_PAYLOAD, DEFAULT_FETCH_TESTCASES_PAYLOAD, } from "../types/testcase.js";
2
+ import { DEFAULT_CREATE_TESTCASES_PAYLOAD, DEFAULT_FETCH_TESTCASE_DETAILS_PAYLOAD, DEFAULT_FETCH_TESTCASE_EXECUTIONS_PAYLOAD, DEFAULT_FETCH_TESTCASE_STEPS_PAYLOAD, DEFAULT_FETCH_TESTCASE_VERSION_DETAILS_PAYLOAD, DEFAULT_FETCH_TESTCASES_LINKED_TO_REQUIREMENT_PAYLOAD, DEFAULT_FETCH_TESTCASES_PAYLOAD, DEFAULT_LINKED_REQUIREMENT_TO_TESTCASE_PAYLOAD, DEFAULT_UPDATE_TESTCASES_PAYLOAD, } from "../types/testcase.js";
4
3
  import { qmetryRequest } from "./api/client-api.js";
5
- function resolveDefaults(baseUrl, project) {
6
- return {
7
- resolvedBaseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
8
- resolvedProject: project || QMETRY_DEFAULTS.PROJECT_KEY,
4
+ import { resolveDefaults } from "./utils.js";
5
+ /**
6
+ * Create test cases.
7
+ * @throws If `tcFolderID` or `name` are missing/invalid.
8
+ */
9
+ export async function createTestCases(token, baseUrl, project, payload) {
10
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
11
+ const body = {
12
+ ...DEFAULT_CREATE_TESTCASES_PAYLOAD,
13
+ ...payload,
14
+ };
15
+ if (typeof body.tcFolderID !== "string") {
16
+ throw new Error("[createTestCases] Missing or invalid required parameter: 'tcFolderID'.");
17
+ }
18
+ if (typeof body.name !== "string") {
19
+ throw new Error("[createTestCases] Missing or invalid required parameter: 'name'.");
20
+ }
21
+ return qmetryRequest({
22
+ method: "POST",
23
+ path: QMETRY_PATHS.TESTCASE.CREATE_UPDATE_TC,
24
+ token,
25
+ project: resolvedProject,
26
+ baseUrl: resolvedBaseUrl,
27
+ body,
28
+ });
29
+ }
30
+ /**
31
+ * Update test cases.
32
+ * @throws If `tcID` or `tcVersionID` are missing/invalid.
33
+ */
34
+ export async function updateTestCase(token, baseUrl, project, payload) {
35
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
36
+ const body = {
37
+ ...DEFAULT_UPDATE_TESTCASES_PAYLOAD,
38
+ ...payload,
9
39
  };
40
+ if (typeof body.tcID !== "number") {
41
+ throw new Error("[updateTestCase] Missing or invalid required parameter: 'tcID'.");
42
+ }
43
+ if (typeof body.tcVersionID !== "number") {
44
+ throw new Error("[updateTestCase] Missing or invalid required parameter: 'tcVersionID'.");
45
+ }
46
+ return qmetryRequest({
47
+ method: "PUT",
48
+ path: QMETRY_PATHS.TESTCASE.CREATE_UPDATE_TC,
49
+ token,
50
+ project: resolvedProject,
51
+ baseUrl: resolvedBaseUrl,
52
+ body,
53
+ });
10
54
  }
11
55
  /**
12
56
  * Fetches a list of test cases.
@@ -102,3 +146,75 @@ export async function fetchTestCaseSteps(token, baseUrl, project, payload) {
102
146
  body,
103
147
  });
104
148
  }
149
+ /**
150
+ * Fetches test cases linked to a specific requirement.
151
+ * @throws If `rqID` is missing/invalid.
152
+ */
153
+ export async function fetchTestCasesLinkedToRequirement(token, baseUrl, project, payload) {
154
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
155
+ const body = {
156
+ ...DEFAULT_FETCH_TESTCASES_LINKED_TO_REQUIREMENT_PAYLOAD,
157
+ ...payload,
158
+ };
159
+ if (typeof body.rqID !== "number") {
160
+ throw new Error("[fetchTestCasesLinkedToRequirement] Missing or invalid required parameter: 'rqID'.");
161
+ }
162
+ return qmetryRequest({
163
+ method: "POST",
164
+ path: QMETRY_PATHS.TESTCASE.GET_TC_LINKED_TO_RQ,
165
+ token,
166
+ project: resolvedProject,
167
+ baseUrl: resolvedBaseUrl,
168
+ body,
169
+ });
170
+ }
171
+ /**
172
+ * Fetches executions for a specific test case.
173
+ * @throws If `tcid` is missing/invalid.
174
+ */
175
+ export async function fetchTestCaseExecutions(token, baseUrl, project, payload) {
176
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
177
+ const body = {
178
+ ...DEFAULT_FETCH_TESTCASE_EXECUTIONS_PAYLOAD,
179
+ ...payload,
180
+ };
181
+ if (typeof body.tcid !== "number") {
182
+ throw new Error("[fetchTestCaseExecutions] Missing or invalid required parameter: 'tcid'.");
183
+ }
184
+ return qmetryRequest({
185
+ method: "POST",
186
+ path: QMETRY_PATHS.TESTCASE.GET_TC_EXECUTIONS,
187
+ token,
188
+ project: resolvedProject,
189
+ baseUrl: resolvedBaseUrl,
190
+ body,
191
+ });
192
+ }
193
+ /**
194
+ * Links a requirement to a test case.
195
+ * @throws If `tcID` or `tcVersionID` or `rqVersionIds` are missing/invalid.
196
+ */
197
+ export async function linkRequirementToTestCase(token, baseUrl, project, payload) {
198
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
199
+ const body = {
200
+ ...DEFAULT_LINKED_REQUIREMENT_TO_TESTCASE_PAYLOAD,
201
+ ...payload,
202
+ };
203
+ if (typeof body.tcID !== "string") {
204
+ throw new Error("[linkRequirementToTestCase] Missing or invalid required parameter: 'tcID'.");
205
+ }
206
+ if (typeof body.tcVersionId !== "number") {
207
+ throw new Error("[linkRequirementToTestCase] Missing or invalid required parameter: 'tcVersionId'.");
208
+ }
209
+ if (typeof body.rqVersionIds !== "string") {
210
+ throw new Error("[linkRequirementToTestCase] Missing or invalid required parameter: 'rqVersionIds'.");
211
+ }
212
+ return qmetryRequest({
213
+ method: "PUT",
214
+ path: QMETRY_PATHS.TESTCASE.LINKED_RQ_TO_TC,
215
+ token,
216
+ project: resolvedProject,
217
+ baseUrl: resolvedBaseUrl,
218
+ body,
219
+ });
220
+ }
@@ -0,0 +1,272 @@
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";
3
+ import { qmetryRequest } from "./api/client-api.js";
4
+ import { resolveDefaults } from "./utils.js";
5
+ /**
6
+ * Create test suites.
7
+ * @throws If `parentFolderId` or `name` are missing/invalid.
8
+ */
9
+ export async function createTestSuites(token, baseUrl, project, payload) {
10
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
11
+ const body = {
12
+ ...DEFAULT_CREATE_TESTSUITE_PAYLOAD,
13
+ ...payload,
14
+ };
15
+ if (typeof body.parentFolderId !== "string") {
16
+ throw new Error("[createTestSuites] Missing or invalid required parameter: 'parentFolderId'.");
17
+ }
18
+ if (typeof body.name !== "string") {
19
+ throw new Error("[createTestSuites] Missing or invalid required parameter: 'name'.");
20
+ }
21
+ return qmetryRequest({
22
+ method: "POST",
23
+ path: QMETRY_PATHS.TESTSUITE.CREATE_UPDATE_TS,
24
+ token,
25
+ project: resolvedProject,
26
+ baseUrl: resolvedBaseUrl,
27
+ body,
28
+ });
29
+ }
30
+ /**
31
+ * Update test suites.
32
+ * @throws If `id` or `entityKey` or `TsFolderID` are missing/invalid.
33
+ */
34
+ export async function updateTestSuite(token, baseUrl, project, payload) {
35
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
36
+ const body = {
37
+ ...DEFAULT_UPDATE_TESTSUITE_PAYLOAD,
38
+ ...payload,
39
+ };
40
+ if (typeof body.id !== "number") {
41
+ throw new Error("[updateTestSuite] Missing or invalid required parameter: 'id'.");
42
+ }
43
+ if (typeof body.entityKey !== "string") {
44
+ throw new Error("[updateTestSuite] Missing or invalid required parameter: 'entityKey'.");
45
+ }
46
+ if (typeof body.TsFolderID !== "number") {
47
+ throw new Error("[updateTestSuite] Missing or invalid required parameter: 'TsFolderID'.");
48
+ }
49
+ return qmetryRequest({
50
+ method: "PUT",
51
+ path: QMETRY_PATHS.TESTSUITE.CREATE_UPDATE_TS,
52
+ token,
53
+ project: resolvedProject,
54
+ baseUrl: resolvedBaseUrl,
55
+ body,
56
+ });
57
+ }
58
+ /**
59
+ * Fetches a list of test suites.
60
+ * @throws If `viewId` or `folderPath` are missing/invalid.
61
+ */
62
+ export async function fetchTestSuites(token, baseUrl, project, payload) {
63
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
64
+ const body = {
65
+ ...DEFAULT_FETCH_TESTSUITES_PAYLOAD,
66
+ ...payload,
67
+ };
68
+ if (typeof body.viewId !== "number") {
69
+ throw new Error("[fetchTestSuites] Missing or invalid required parameter: 'viewId'.");
70
+ }
71
+ if (typeof body.folderPath !== "string") {
72
+ throw new Error("[fetchTestSuites] Missing or invalid required parameter: 'folderPath'.");
73
+ }
74
+ return qmetryRequest({
75
+ method: "POST",
76
+ path: QMETRY_PATHS.TESTSUITE.GET_TS_LIST,
77
+ token,
78
+ project: resolvedProject,
79
+ baseUrl: resolvedBaseUrl,
80
+ body,
81
+ });
82
+ }
83
+ /**
84
+ * Fetches test suites to link with test case.
85
+ * @throws If `tsFolderID` is missing/invalid.
86
+ */
87
+ export async function fetchTestSuitesForTestCase(token, baseUrl, project, payload) {
88
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
89
+ const body = {
90
+ ...DEFAULT_FETCH_TESTSUITES_FOR_TESTCASE_PAYLOAD,
91
+ ...payload,
92
+ };
93
+ if (typeof body.tsFolderID !== "number") {
94
+ throw new Error("[fetchTestSuitesForTestCase] Missing or invalid required parameter: 'tsFolderID'.");
95
+ }
96
+ return qmetryRequest({
97
+ method: "POST",
98
+ path: QMETRY_PATHS.TESTSUITE.GET_TS_LIST_FOR_TC,
99
+ token,
100
+ project: resolvedProject,
101
+ baseUrl: resolvedBaseUrl,
102
+ body,
103
+ });
104
+ }
105
+ /**
106
+ * Fetches test cases linked to a given test suite.
107
+ * @throws If `tsID` is missing/invalid.
108
+ */
109
+ export async function fetchTestCasesByTestSuite(token, baseUrl, project, payload) {
110
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
111
+ const body = {
112
+ ...DEFAULT_FETCH_TESTCASES_BY_TESTSUITE_PAYLOAD,
113
+ ...payload,
114
+ };
115
+ if (typeof body.tsID !== "number") {
116
+ throw new Error("[fetchTestCasesByTestSuite] Missing or invalid required parameter: 'tsID'.");
117
+ }
118
+ return qmetryRequest({
119
+ method: "POST",
120
+ path: QMETRY_PATHS.TESTSUITE.GET_TESTCASES_BY_TESTSUITE,
121
+ token,
122
+ project: resolvedProject,
123
+ baseUrl: resolvedBaseUrl,
124
+ body,
125
+ });
126
+ }
127
+ /**
128
+ * Fetches executions for a given test suite.
129
+ * @throws If `tsID` is missing/invalid.
130
+ */
131
+ export async function fetchExecutionsByTestSuite(token, baseUrl, project, payload) {
132
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
133
+ const body = {
134
+ ...DEFAULT_FETCH_EXECUTIONS_BY_TESTSUITE_PAYLOAD,
135
+ ...payload,
136
+ };
137
+ if (typeof body.tsID !== "number") {
138
+ throw new Error("[fetchExecutionsByTestSuite] Missing or invalid required parameter: 'tsID'.");
139
+ }
140
+ return qmetryRequest({
141
+ method: "POST",
142
+ path: QMETRY_PATHS.TESTSUITE.GET_EXECUTIONS_BY_TESTSUITE,
143
+ token,
144
+ project: resolvedProject,
145
+ baseUrl: resolvedBaseUrl,
146
+ body,
147
+ });
148
+ }
149
+ /**
150
+ * Fetches test case runs for a given test suite run ID.
151
+ * @throws If `tsrunID` or `viewId` is missing/invalid.
152
+ */
153
+ export async function fetchTestCaseRunsByTestSuiteRun(token, baseUrl, project, payload) {
154
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
155
+ const body = {
156
+ ...DEFAULT_FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN_PAYLOAD,
157
+ ...payload,
158
+ };
159
+ if (typeof body.tsrunID !== "string" || !body.tsrunID) {
160
+ throw new Error("[fetchTestCaseRunsByTestSuiteRun] Missing or invalid required parameter: 'tsrunID'.");
161
+ }
162
+ if (typeof body.viewId !== "number") {
163
+ throw new Error("[fetchTestCaseRunsByTestSuiteRun] Missing or invalid required parameter: 'viewId'.");
164
+ }
165
+ return qmetryRequest({
166
+ method: "POST",
167
+ path: QMETRY_PATHS.TESTSUITE.GET_TESTCASE_RUNS_BY_TESTSUITE_RUN,
168
+ token,
169
+ project: resolvedProject,
170
+ baseUrl: resolvedBaseUrl,
171
+ body,
172
+ });
173
+ }
174
+ /**
175
+ * Fetches linked issues for a specific test case run.
176
+ * @throws If `entityId` is missing/invalid.
177
+ */
178
+ export async function fetchLinkedIssuesByTestCaseRun(token, baseUrl, project, payload) {
179
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
180
+ const body = {
181
+ ...DEFAULT_FETCH_LINKED_ISSUES_BY_TESTCASE_RUN_PAYLOAD,
182
+ ...payload,
183
+ };
184
+ if (typeof body.entityId !== "number") {
185
+ throw new Error("[fetchLinkedIssuesByTestCaseRun] Missing or invalid required parameter: 'entityId'.");
186
+ }
187
+ return qmetryRequest({
188
+ method: "POST",
189
+ path: QMETRY_PATHS.TESTSUITE.GET_LINKED_ISSUES_BY_TESTCASE_RUN,
190
+ token,
191
+ project: resolvedProject,
192
+ baseUrl: resolvedBaseUrl,
193
+ body,
194
+ });
195
+ }
196
+ /**
197
+ * Link test cases to a test suite.
198
+ * @throws If `tcID` or `tcVersionID` are missing/invalid.
199
+ */
200
+ export async function linkTestCasesToTestSuite(token, baseUrl, project, payload) {
201
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
202
+ const body = {
203
+ ...DEFAULT_LINKED_TESTCASE_TO_TESTSUITE_PAYLOAD,
204
+ ...payload,
205
+ };
206
+ if (typeof body.tsID !== "number") {
207
+ throw new Error("[linkTestCasesToTestSuite] Missing or invalid required parameter: 'tsID'.");
208
+ }
209
+ if (!body.tcvdIDs) {
210
+ throw new Error("[linkTestCasesToTestSuite] 'tcvdIDs' must be provided.");
211
+ }
212
+ return qmetryRequest({
213
+ method: "PUT",
214
+ path: QMETRY_PATHS.TESTSUITE.LINKED_TESTCASES_TO_TESTSUITE,
215
+ token,
216
+ project: resolvedProject,
217
+ baseUrl: resolvedBaseUrl,
218
+ body,
219
+ });
220
+ }
221
+ /**
222
+ * Requirements Linked test cases to a test suite.
223
+ * @throws If `tcID` or `rqVersionIds` are missing/invalid.
224
+ */
225
+ export async function reqLinkedTestCasesToTestSuite(token, baseUrl, project, payload) {
226
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
227
+ const body = {
228
+ ...DEFAULT_REQLINKED_TESTCASE_TO_TESTSUITE_PAYLOAD,
229
+ ...payload,
230
+ };
231
+ if (typeof body.tsID !== "number") {
232
+ throw new Error("[reqLinkedTestCasesToTestSuite] Missing or invalid required parameter: 'tsID'.");
233
+ }
234
+ if (!body.tcvdIDs) {
235
+ throw new Error("[reqLinkedTestCasesToTestSuite] 'tcvdIDs' must be provided.");
236
+ }
237
+ return qmetryRequest({
238
+ method: "PUT",
239
+ path: QMETRY_PATHS.TESTSUITE.LINKED_TESTCASES_TO_TESTSUITE,
240
+ token,
241
+ project: resolvedProject,
242
+ baseUrl: resolvedBaseUrl,
243
+ body,
244
+ });
245
+ }
246
+ /**
247
+ * Link platforms to a test suite.
248
+ * @throws If `qmTsId` or `qmPlatformId` are missing/invalid.
249
+ */
250
+ export async function linkPlatformsToTestSuite(token, baseUrl, project, payload) {
251
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
252
+ const body = {
253
+ ...DEFAULT_LINKED_PLATFORMS_TO_TESTSUITE_PAYLOAD,
254
+ ...payload,
255
+ };
256
+ if (typeof body.qmTsId !== "number") {
257
+ throw new Error("[linkPlatformsToTestSuite] Missing or invalid required parameter: 'qmTsId'.");
258
+ }
259
+ if (!body.qmPlatformId ||
260
+ typeof body.qmPlatformId !== "string" ||
261
+ body.qmPlatformId.trim().length === 0) {
262
+ throw new Error("[linkPlatformsToTestSuite] Missing or invalid required parameter: 'qmPlatformId'. It must be a non-empty comma-separated string of Platform IDs.");
263
+ }
264
+ return qmetryRequest({
265
+ method: "PUT",
266
+ path: QMETRY_PATHS.TESTSUITE.LINK_PLATFORMS_TO_TESTSUITE,
267
+ token,
268
+ project: resolvedProject,
269
+ baseUrl: resolvedBaseUrl,
270
+ body,
271
+ });
272
+ }