@smartbear/mcp 0.31.0 → 0.32.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.
- package/dist/package.json.js +1 -1
- package/dist/qtm4j/client.js +14 -0
- package/dist/qtm4j/config/constants.js +83 -2
- package/dist/qtm4j/config/field-resolution.types.js +12 -2
- package/dist/qtm4j/http/api-client.js +30 -4
- package/dist/qtm4j/http/auth-service.js +3 -2
- package/dist/qtm4j/resolver/resolver-registry.js +37 -1
- package/dist/qtm4j/resolver/resolvers/build-resolver.js +51 -0
- package/dist/qtm4j/resolver/resolvers/common-attribute-resolver.js +1 -3
- package/dist/qtm4j/resolver/resolvers/component-resolver.js +1 -1
- package/dist/qtm4j/resolver/resolvers/defect-id-resolver.js +44 -0
- package/dist/qtm4j/resolver/resolvers/defect-priority-resolver.js +55 -0
- package/dist/qtm4j/resolver/resolvers/defect-status-resolver.js +55 -0
- package/dist/qtm4j/resolver/resolvers/environment-resolver.js +51 -0
- package/dist/qtm4j/resolver/resolvers/execution-context-resolver.js +58 -0
- package/dist/qtm4j/resolver/resolvers/label-resolver.js +1 -1
- package/dist/qtm4j/resolver/resolvers/requirement-id-resolver.js +3 -4
- package/dist/qtm4j/resolver/resolvers/step-execution-context-resolver.js +62 -0
- package/dist/qtm4j/resolver/resolvers/test-case-uid-resolver.js +3 -4
- package/dist/qtm4j/resolver/resolvers/test-cycle-uid-resolver.js +3 -4
- package/dist/qtm4j/schema/get-bugs.schema.js +101 -0
- package/dist/qtm4j/schema/get-test-case.schema.js +3 -3
- package/dist/qtm4j/schema/link-bugs.schema.js +63 -0
- package/dist/qtm4j/schema/start-execution.schema.js +45 -0
- package/dist/qtm4j/schema/test-cycle.link.schema.js +10 -1
- package/dist/qtm4j/schema/update-test-case-execution.schema.js +41 -0
- package/dist/qtm4j/schema/update-test-step-execution.schema.js +41 -0
- package/dist/qtm4j/tool/project/get-projects.js +3 -3
- package/dist/qtm4j/tool/project/set-project-context.js +1 -1
- package/dist/qtm4j/tool/test-automation/get-automation-history.js +4 -7
- package/dist/qtm4j/tool/test-automation/upload-automation-result.js +4 -2
- package/dist/qtm4j/tool/test-execution/get-test-case-bugs.js +119 -0
- package/dist/qtm4j/tool/test-execution/get-test-step-bugs.js +122 -0
- package/dist/qtm4j/tool/test-execution/link-test-case-bugs.js +135 -0
- package/dist/qtm4j/tool/test-execution/link-test-step-bugs.js +140 -0
- package/dist/qtm4j/tool/test-execution/start-execution.js +150 -0
- package/dist/qtm4j/tool/test-execution/update-test-case-execution.js +123 -0
- package/dist/qtm4j/tool/test-execution/update-test-step-execution.js +126 -0
- package/dist/swagger/client/api.js +8 -1
- package/dist/swagger/client/user-management-types.js +2 -1
- package/package.json +1 -1
package/dist/package.json.js
CHANGED
package/dist/qtm4j/client.js
CHANGED
|
@@ -122,6 +122,13 @@ class Qtm4jClient {
|
|
|
122
122
|
const { LinkRequirementsToCycle } = await import("./tool/test-cycle/link-requirements.js");
|
|
123
123
|
const { UnlinkRequirementsFromCycle } = await import("./tool/test-cycle/unlink-requirements.js");
|
|
124
124
|
const { GetLinkedRequirementsForCycle } = await import("./tool/test-cycle/get-linked-requirements.js");
|
|
125
|
+
const { StartExecution } = await import("./tool/test-execution/start-execution.js");
|
|
126
|
+
const { UpdateTestCaseExecution } = await import("./tool/test-execution/update-test-case-execution.js");
|
|
127
|
+
const { UpdateTestStepExecution } = await import("./tool/test-execution/update-test-step-execution.js");
|
|
128
|
+
const { LinkTestCaseBugs } = await import("./tool/test-execution/link-test-case-bugs.js");
|
|
129
|
+
const { LinkTestStepBugs } = await import("./tool/test-execution/link-test-step-bugs.js");
|
|
130
|
+
const { GetTestCaseBugs } = await import("./tool/test-execution/get-test-case-bugs.js");
|
|
131
|
+
const { GetTestStepBugs } = await import("./tool/test-execution/get-test-step-bugs.js");
|
|
125
132
|
const tools = [
|
|
126
133
|
new GetProjects(this),
|
|
127
134
|
new SetProjectContext(this),
|
|
@@ -132,6 +139,13 @@ class Qtm4jClient {
|
|
|
132
139
|
new CreateTestCycle(this),
|
|
133
140
|
new SearchTestCycles(this),
|
|
134
141
|
new UpdateTestCycle(this),
|
|
142
|
+
new StartExecution(this),
|
|
143
|
+
new UpdateTestCaseExecution(this),
|
|
144
|
+
new UpdateTestStepExecution(this),
|
|
145
|
+
new LinkTestCaseBugs(this),
|
|
146
|
+
new LinkTestStepBugs(this),
|
|
147
|
+
new GetTestCaseBugs(this),
|
|
148
|
+
new GetTestStepBugs(this),
|
|
135
149
|
new UploadAutomationResult(this),
|
|
136
150
|
new GetAutomationHistory(this),
|
|
137
151
|
new LinkRequirements(this),
|
|
@@ -56,6 +56,34 @@ const ENDPOINTS = {
|
|
|
56
56
|
LABELS: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/labels`,
|
|
57
57
|
/** Components search endpoint */
|
|
58
58
|
COMPONENTS: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/components`,
|
|
59
|
+
/** Environments search endpoint (resolve environment name → ID for executions) */
|
|
60
|
+
ENVIRONMENTS: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/environments`,
|
|
61
|
+
/** Builds search endpoint (resolve build name → ID for executions) */
|
|
62
|
+
BUILDS: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/builds`,
|
|
63
|
+
/** Resolve defect issue keys → Jira numeric issueIds for a given project */
|
|
64
|
+
RESOLVE_DEFECT_IDS: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/defects/resolve-ids`,
|
|
65
|
+
/** Resolve defect status names → internal status IDs for a given project */
|
|
66
|
+
DEFECT_STATUSES: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/defects/statuses`,
|
|
67
|
+
/** Resolve defect priority names → internal priority IDs for a given project */
|
|
68
|
+
DEFECT_PRIORITIES: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/defects/priorities`,
|
|
69
|
+
/** Resolve execution context (testCycleTestCaseMapId + testCaseExecutionId) by issue keys */
|
|
70
|
+
EXECUTION_CONTEXT: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/testcycles/execution-context`,
|
|
71
|
+
/** Resolve step execution context (seqNo → testStepExecutionId) for a test case execution */
|
|
72
|
+
STEP_EXECUTION_CONTEXT: (projectId) => `${API_CONFIG.API_VERSION}/projects/${projectId}/mcp/testcycles/step-execution-context`,
|
|
73
|
+
/** Start new test case execution */
|
|
74
|
+
START_NEW_EXECUTION: (cycleKey, testCycleTestCaseMapId) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/testcases/${testCycleTestCaseMapId}/executions`,
|
|
75
|
+
/** Update test case execution */
|
|
76
|
+
UPDATE_TEST_CASE_EXECUTION: (cycleKey, testCaseExecutionId) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/testcase-executions/${testCaseExecutionId}`,
|
|
77
|
+
/** Update test step execution */
|
|
78
|
+
UPDATE_TEST_STEP_EXECUTION: (cycleKey, testStepExecutionId) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/teststep-executions/${testStepExecutionId}`,
|
|
79
|
+
/** Link bugs to test case execution */
|
|
80
|
+
LINK_BUGS_TEST_CASE_EXECUTION: (cycleKey, testCaseExecutionId, returnLinkedDefectCount) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/testcase-executions/${testCaseExecutionId}/defects${returnLinkedDefectCount ? "?returnLinkedDefectCount=true" : ""}`,
|
|
81
|
+
/** Link bugs to test step execution */
|
|
82
|
+
LINK_BUGS_TEST_STEP_EXECUTION: (cycleKey, testStepExecutionId, returnLinkedDefectCount) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/teststep-executions/${testStepExecutionId}/defects${returnLinkedDefectCount ? "?returnLinkedDefectCount=true" : ""}`,
|
|
83
|
+
/** Get linked bugs for a test case execution (POST with filter body) */
|
|
84
|
+
GET_LINKED_BUGS_TEST_CASE_EXECUTION: (cycleKey, testCaseExecutionId) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/testcase-executions/${testCaseExecutionId}/defects`,
|
|
85
|
+
/** Get linked bugs for a test step execution (POST with filter body) */
|
|
86
|
+
GET_LINKED_BUGS_TEST_STEP_EXECUTION: (cycleKey, testStepExecutionId) => `${API_CONFIG.API_VERSION}/testcycles/${cycleKey}/teststep-executions/${testStepExecutionId}/defects`,
|
|
59
87
|
/** Automation: initiate result file import — returns pre-signed S3 upload URL + trackingId */
|
|
60
88
|
AUTOMATION_IMPORT: "/rest/api/automation/importresult",
|
|
61
89
|
/** Automation: poll import progress by trackingId */
|
|
@@ -73,7 +101,11 @@ const HTTP_HEADERS = {
|
|
|
73
101
|
/** Accept header */
|
|
74
102
|
ACCEPT: "Accept",
|
|
75
103
|
/** Content length header */
|
|
76
|
-
CONTENT_LENGTH: "content-length"
|
|
104
|
+
CONTENT_LENGTH: "content-length",
|
|
105
|
+
/** Identifies the request source for backend analytics (e.g., Amplitude) */
|
|
106
|
+
X_REQUEST_SOURCE: "X-Request-Source",
|
|
107
|
+
/** Signals whether analytics tracking is allowed for this request */
|
|
108
|
+
X_ALLOW_TRACKING: "X-Allow-Tracking"
|
|
77
109
|
};
|
|
78
110
|
const CONTENT_TYPES = {
|
|
79
111
|
/** JSON content type */
|
|
@@ -94,11 +126,17 @@ const HTTP_STATUS = {
|
|
|
94
126
|
const CLIENT_CONFIG = {
|
|
95
127
|
/** Client name */
|
|
96
128
|
NAME: "QTM4J",
|
|
129
|
+
/** Fixed value sent in X-Request-Source to identify MCP-originated requests */
|
|
130
|
+
SOURCE_VALUE: "QTM4J_MCP",
|
|
97
131
|
/** Tool prefix for all QTM4J tools */
|
|
98
132
|
TOOL_PREFIX: "qtm4j",
|
|
99
133
|
/** Configuration prefix */
|
|
100
134
|
CONFIG_PREFIX: "Qtm4j"
|
|
101
135
|
};
|
|
136
|
+
const IMPORT_BODY_FIELDS = {
|
|
137
|
+
REQUEST_SOURCE: "xRequestSource",
|
|
138
|
+
ALLOW_TRACKING: "xAllowTracking"
|
|
139
|
+
};
|
|
102
140
|
const PAGINATION = {
|
|
103
141
|
/** Default starting position for pagination */
|
|
104
142
|
DEFAULT_START_AT: 0,
|
|
@@ -119,7 +157,11 @@ const PAGINATION = {
|
|
|
119
157
|
/** Maximum allowed results per request for test cycles */
|
|
120
158
|
MAX_ALLOWED_RESULTS_TEST_CYCLES: 100,
|
|
121
159
|
/** Minimum allowed results per request */
|
|
122
|
-
MIN_ALLOWED_RESULTS: 1
|
|
160
|
+
MIN_ALLOWED_RESULTS: 1,
|
|
161
|
+
/** Default maximum results for linked bugs */
|
|
162
|
+
DEFAULT_MAX_RESULTS_LINKED_BUGS: 20,
|
|
163
|
+
/** Maximum allowed results per request for linked bugs */
|
|
164
|
+
MAX_ALLOWED_RESULTS_LINKED_BUGS: 100
|
|
123
165
|
};
|
|
124
166
|
const AUTOMATION_LIMITS = {
|
|
125
167
|
/** Maximum allowed upload file size in bytes (10 MB) */
|
|
@@ -248,6 +290,41 @@ const TOOL_NAMES = {
|
|
|
248
290
|
UNLINK_REQUIREMENTS_FROM_CYCLE: {
|
|
249
291
|
TITLE: "Unlink Requirements from Test Cycle",
|
|
250
292
|
SUMMARY: "Unlink one or more Jira requirements from a QTM4J test cycle by requirement keys, or unlink all requirements at once with unLinkAll."
|
|
293
|
+
},
|
|
294
|
+
/** Start a New Execution tool */
|
|
295
|
+
START_NEW_EXECUTION: {
|
|
296
|
+
TITLE: "Start New Execution",
|
|
297
|
+
SUMMARY: "Start a new test case execution within a test cycle. Looks up the internal map ID from testCycleKey and testCaseKey; resolves environmentId and buildId names to numeric IDs."
|
|
298
|
+
},
|
|
299
|
+
/** Update Test Case Execution tool */
|
|
300
|
+
UPDATE_TEST_CASE_EXECUTION: {
|
|
301
|
+
TITLE: "Update Test Case Execution",
|
|
302
|
+
SUMMARY: "Update a test case execution (execution result, comment, environment, build, assignee, planned date, actual time). Looks up testCaseExecutionId from testCycleKey and testCaseKey; resolves executionResultId, environmentId, and buildId names to numeric IDs."
|
|
303
|
+
},
|
|
304
|
+
/** Update Test Step Execution tool */
|
|
305
|
+
UPDATE_TEST_STEP_EXECUTION: {
|
|
306
|
+
TITLE: "Update Test Step Execution",
|
|
307
|
+
SUMMARY: "Update a test step execution (execution result, actual result, comment). Looks up testStepExecutionId from testCycleKey, testCaseKey, and step sequence number; resolves executionResultId name to a numeric ID."
|
|
308
|
+
},
|
|
309
|
+
/** Link Bugs to Test Case Execution tool */
|
|
310
|
+
LINK_BUGS_TO_TEST_CASE_EXECUTION: {
|
|
311
|
+
TITLE: "Link Bugs to Test Case Execution",
|
|
312
|
+
SUMMARY: "Link Jira bug keys to a test case execution. Looks up testCaseExecutionId from testCycleKey and testCaseKey; resolves bug keys to numeric defect IDs automatically."
|
|
313
|
+
},
|
|
314
|
+
/** Link Bugs to Test Step Execution tool */
|
|
315
|
+
LINK_BUGS_TO_TEST_STEP_EXECUTION: {
|
|
316
|
+
TITLE: "Link Bugs to Test Step Execution",
|
|
317
|
+
SUMMARY: "Link Jira bug keys to a test step execution. Looks up testStepExecutionId from testCycleKey, testCaseKey, and step sequence number; resolves bug keys to numeric defect IDs automatically."
|
|
318
|
+
},
|
|
319
|
+
/** Get Linked Bugs of Test Case Execution tool */
|
|
320
|
+
GET_LINKED_BUGS_OF_TEST_CASE_EXECUTION: {
|
|
321
|
+
TITLE: "Get Linked Bugs of Test Case Execution",
|
|
322
|
+
SUMMARY: "Retrieve Jira bugs linked to a test case execution with optional priority and status filtering. Looks up testCaseExecutionId from testCycleKey and testCaseKey; resolves filter names to numeric IDs."
|
|
323
|
+
},
|
|
324
|
+
/** Get Linked Bugs of Test Step Execution tool */
|
|
325
|
+
GET_LINKED_BUGS_OF_TEST_STEP_EXECUTION: {
|
|
326
|
+
TITLE: "Get Linked Bugs of Test Step Execution",
|
|
327
|
+
SUMMARY: "Retrieve Jira bugs linked to a test step execution with optional priority and status filtering. Looks up testStepExecutionId from testCycleKey, testCaseKey, and step sequence number; resolves filter names to numeric IDs."
|
|
251
328
|
}
|
|
252
329
|
};
|
|
253
330
|
const TOOLSETS = {
|
|
@@ -257,8 +334,11 @@ const TOOLSETS = {
|
|
|
257
334
|
TEST_CASES: "Test Cases",
|
|
258
335
|
/** Test Cycle Management toolset */
|
|
259
336
|
TEST_CYCLES: "Test Cycles",
|
|
337
|
+
/** Test Executions toolset */
|
|
338
|
+
TEST_EXECUTIONS: "Test Executions",
|
|
260
339
|
/** Projects toolset */
|
|
261
340
|
PROJECTS: "Projects",
|
|
341
|
+
/** Requirements toolset */
|
|
262
342
|
REQUIREMENTS: "Requirements"
|
|
263
343
|
};
|
|
264
344
|
const CONFIG_KEYS = {
|
|
@@ -352,6 +432,7 @@ export {
|
|
|
352
432
|
HTTP_HEADERS,
|
|
353
433
|
HTTP_METHODS,
|
|
354
434
|
HTTP_STATUS,
|
|
435
|
+
IMPORT_BODY_FIELDS,
|
|
355
436
|
PAGINATION,
|
|
356
437
|
RESPONSE_FIELDS,
|
|
357
438
|
SCHEMA_DESCRIPTIONS,
|
|
@@ -9,7 +9,8 @@ const ResolverKeys = {
|
|
|
9
9
|
TEST_CYCLE_STATUS: "testcycle_status",
|
|
10
10
|
PRIORITY: "priority",
|
|
11
11
|
TESTCASE_FOLDER: "testcase_folder",
|
|
12
|
-
TEST_CYCLE_FOLDER: "testcycle_folder"
|
|
12
|
+
TEST_CYCLE_FOLDER: "testcycle_folder",
|
|
13
|
+
EXECUTION_RESULT: "execution_result"
|
|
13
14
|
},
|
|
14
15
|
/**
|
|
15
16
|
* Fields with dedicated search APIs (fetched on-demand, not batch-loaded).
|
|
@@ -20,7 +21,14 @@ const ResolverKeys = {
|
|
|
20
21
|
COMPONENTS: "components",
|
|
21
22
|
TEST_CASE_KEY_TO_UID: "testCaseKeyToUid",
|
|
22
23
|
TEST_CYCLE_KEY_TO_UID: "testCycleKeyToUid",
|
|
23
|
-
REQUIREMENT_KEY_TO_ID: "requirementKeyToId"
|
|
24
|
+
REQUIREMENT_KEY_TO_ID: "requirementKeyToId",
|
|
25
|
+
ENVIRONMENT: "environment",
|
|
26
|
+
BUILD: "build",
|
|
27
|
+
DEFECT_KEY_TO_ID: "defectKeyToId",
|
|
28
|
+
DEFECT_STATUS: "defectStatus",
|
|
29
|
+
DEFECT_PRIORITY: "defectPriority",
|
|
30
|
+
EXECUTION_CONTEXT: "executionContext",
|
|
31
|
+
STEP_EXECUTION_CONTEXT: "stepExecutionContext"
|
|
24
32
|
}
|
|
25
33
|
};
|
|
26
34
|
var InputField = /* @__PURE__ */ ((InputField2) => {
|
|
@@ -29,6 +37,8 @@ var InputField = /* @__PURE__ */ ((InputField2) => {
|
|
|
29
37
|
InputField2["COMPONENTS"] = "components";
|
|
30
38
|
InputField2["LABELS"] = "labels";
|
|
31
39
|
InputField2["FOLDER"] = "folderId";
|
|
40
|
+
InputField2["ENVIRONMENT"] = "environment";
|
|
41
|
+
InputField2["BUILD"] = "build";
|
|
32
42
|
return InputField2;
|
|
33
43
|
})(InputField || {});
|
|
34
44
|
export {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ToolError } from "../../common/tools.js";
|
|
2
|
-
import { EMPTY_VALUES, ERROR_MESSAGES, HTTP_METHODS, CONTENT_TYPES,
|
|
2
|
+
import { EMPTY_VALUES, ERROR_MESSAGES, HTTP_HEADERS, HTTP_METHODS, CONTENT_TYPES, HTTP_STATUS } from "../config/constants.js";
|
|
3
3
|
import { AuthService } from "./auth-service.js";
|
|
4
4
|
class ApiClient {
|
|
5
5
|
baseUrl;
|
|
6
6
|
tokenProvider;
|
|
7
7
|
automationTokenProvider;
|
|
8
|
-
|
|
8
|
+
allowTracking;
|
|
9
|
+
_skipInstance;
|
|
10
|
+
constructor(tokenOrProvider, baseUrl, automationTokenProvider, allowTracking = true) {
|
|
9
11
|
this.baseUrl = baseUrl.trim().replace(/\/$/, EMPTY_VALUES.STRING);
|
|
10
12
|
if (typeof tokenOrProvider === "string") {
|
|
11
13
|
this.tokenProvider = () => tokenOrProvider;
|
|
@@ -13,6 +15,24 @@ class ApiClient {
|
|
|
13
15
|
this.tokenProvider = tokenOrProvider;
|
|
14
16
|
}
|
|
15
17
|
this.automationTokenProvider = automationTokenProvider;
|
|
18
|
+
this.allowTracking = allowTracking;
|
|
19
|
+
if (allowTracking) {
|
|
20
|
+
this._skipInstance = new ApiClient(
|
|
21
|
+
this.tokenProvider,
|
|
22
|
+
this.baseUrl,
|
|
23
|
+
this.automationTokenProvider,
|
|
24
|
+
false
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
this._skipInstance = this;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the pre-created ApiClient instance with analytics tracking disabled.
|
|
32
|
+
* Use for resolver and internal calls that should not be tracked.
|
|
33
|
+
*/
|
|
34
|
+
skipAnalytics() {
|
|
35
|
+
return this._skipInstance;
|
|
16
36
|
}
|
|
17
37
|
/**
|
|
18
38
|
* Get authentication headers for current request
|
|
@@ -25,7 +45,10 @@ class ApiClient {
|
|
|
25
45
|
if (!token) {
|
|
26
46
|
throw new ToolError(ERROR_MESSAGES.CLIENT_NOT_CONFIGURED);
|
|
27
47
|
}
|
|
28
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
...new AuthService(token).getAuthHeaders(),
|
|
50
|
+
[HTTP_HEADERS.X_ALLOW_TRACKING]: String(this.allowTracking)
|
|
51
|
+
};
|
|
29
52
|
}
|
|
30
53
|
/**
|
|
31
54
|
* Get authentication headers using the automation API key.
|
|
@@ -36,7 +59,10 @@ class ApiClient {
|
|
|
36
59
|
if (!token) {
|
|
37
60
|
throw new ToolError(ERROR_MESSAGES.AUTOMATION_API_KEY_NOT_CONFIGURED);
|
|
38
61
|
}
|
|
39
|
-
return
|
|
62
|
+
return {
|
|
63
|
+
...new AuthService(token).getAuthHeaders(),
|
|
64
|
+
[HTTP_HEADERS.X_ALLOW_TRACKING]: String(this.allowTracking)
|
|
65
|
+
};
|
|
40
66
|
}
|
|
41
67
|
/**
|
|
42
68
|
* Construct full URL with query parameters
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getUserAgent } from "../../common/info.js";
|
|
2
|
-
import { CONTENT_TYPES, HTTP_HEADERS } from "../config/constants.js";
|
|
2
|
+
import { CLIENT_CONFIG, CONTENT_TYPES, HTTP_HEADERS } from "../config/constants.js";
|
|
3
3
|
class AuthService {
|
|
4
4
|
apiKey;
|
|
5
5
|
constructor(apiKey) {
|
|
@@ -14,7 +14,8 @@ class AuthService {
|
|
|
14
14
|
[HTTP_HEADERS.API_KEY]: this.apiKey,
|
|
15
15
|
[HTTP_HEADERS.CONTENT_TYPE]: CONTENT_TYPES.JSON,
|
|
16
16
|
[HTTP_HEADERS.USER_AGENT]: getUserAgent(),
|
|
17
|
-
[HTTP_HEADERS.ACCEPT]: CONTENT_TYPES.JSON
|
|
17
|
+
[HTTP_HEADERS.ACCEPT]: CONTENT_TYPES.JSON,
|
|
18
|
+
[HTTP_HEADERS.X_REQUEST_SOURCE]: CLIENT_CONFIG.SOURCE_VALUE
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { BuildResolver } from "./resolvers/build-resolver.js";
|
|
1
2
|
import { CommonAttributeResolver } from "./resolvers/common-attribute-resolver.js";
|
|
2
3
|
import { ComponentResolver } from "./resolvers/component-resolver.js";
|
|
4
|
+
import { DefectIdResolver } from "./resolvers/defect-id-resolver.js";
|
|
5
|
+
import { DefectPriorityResolver } from "./resolvers/defect-priority-resolver.js";
|
|
6
|
+
import { DefectStatusResolver } from "./resolvers/defect-status-resolver.js";
|
|
7
|
+
import { EnvironmentResolver } from "./resolvers/environment-resolver.js";
|
|
8
|
+
import { ExecutionContextResolver } from "./resolvers/execution-context-resolver.js";
|
|
3
9
|
import { LabelResolver } from "./resolvers/label-resolver.js";
|
|
4
10
|
import { RequirementIdResolver } from "./resolvers/requirement-id-resolver.js";
|
|
11
|
+
import { StepExecutionContextResolver } from "./resolvers/step-execution-context-resolver.js";
|
|
5
12
|
import { TestCaseUidResolver } from "./resolvers/test-case-uid-resolver.js";
|
|
6
13
|
import { TestCycleUidResolver } from "./resolvers/test-cycle-uid-resolver.js";
|
|
7
14
|
const ERROR_NO_PROJECT_CONTEXT = "No active project set. Please call set_project_context before performing this operation.";
|
|
@@ -20,6 +27,28 @@ class ResolverRegistry {
|
|
|
20
27
|
const componentResolver = new ComponentResolver(apiClient, cacheService);
|
|
21
28
|
const requirementIdResolver = new RequirementIdResolver(apiClient);
|
|
22
29
|
const testcycleUidResolver = new TestCycleUidResolver(apiClient);
|
|
30
|
+
const environmentResolver = new EnvironmentResolver(
|
|
31
|
+
apiClient,
|
|
32
|
+
cacheService
|
|
33
|
+
);
|
|
34
|
+
const buildResolver = new BuildResolver(apiClient, cacheService);
|
|
35
|
+
const defectIdResolver = new DefectIdResolver(apiClient);
|
|
36
|
+
const defectStatusResolver = new DefectStatusResolver(
|
|
37
|
+
apiClient,
|
|
38
|
+
cacheService
|
|
39
|
+
);
|
|
40
|
+
const defectPriorityResolver = new DefectPriorityResolver(
|
|
41
|
+
apiClient,
|
|
42
|
+
cacheService
|
|
43
|
+
);
|
|
44
|
+
const executionContextResolver = new ExecutionContextResolver(
|
|
45
|
+
apiClient,
|
|
46
|
+
cacheService
|
|
47
|
+
);
|
|
48
|
+
const stepExecutionContextResolver = new StepExecutionContextResolver(
|
|
49
|
+
apiClient,
|
|
50
|
+
cacheService
|
|
51
|
+
);
|
|
23
52
|
this.resolverByKey = /* @__PURE__ */ new Map();
|
|
24
53
|
for (const resolver of [
|
|
25
54
|
this.commonAttributes,
|
|
@@ -27,7 +56,14 @@ class ResolverRegistry {
|
|
|
27
56
|
componentResolver,
|
|
28
57
|
this.testCaseUidResolver,
|
|
29
58
|
requirementIdResolver,
|
|
30
|
-
testcycleUidResolver
|
|
59
|
+
testcycleUidResolver,
|
|
60
|
+
environmentResolver,
|
|
61
|
+
buildResolver,
|
|
62
|
+
defectIdResolver,
|
|
63
|
+
defectStatusResolver,
|
|
64
|
+
defectPriorityResolver,
|
|
65
|
+
executionContextResolver,
|
|
66
|
+
stepExecutionContextResolver
|
|
31
67
|
]) {
|
|
32
68
|
for (const key of resolver.fieldKeys) {
|
|
33
69
|
this.resolverByKey.set(key, resolver);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../../config/constants.js";
|
|
2
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
3
|
+
import { Cache } from "../cache/cache.js";
|
|
4
|
+
import { Resolver } from "./resolver.js";
|
|
5
|
+
class BuildResolver extends Resolver {
|
|
6
|
+
fieldKeys = [
|
|
7
|
+
ResolverKeys.SearchableField.BUILD
|
|
8
|
+
];
|
|
9
|
+
cache;
|
|
10
|
+
apiClient;
|
|
11
|
+
constructor(apiClient, cacheService) {
|
|
12
|
+
super();
|
|
13
|
+
this.apiClient = apiClient;
|
|
14
|
+
this.cache = new Cache(cacheService);
|
|
15
|
+
}
|
|
16
|
+
async resolve(inputField, resolverKey, body, context, warnings) {
|
|
17
|
+
const name = body[inputField];
|
|
18
|
+
if (name == null || typeof name === "number") return;
|
|
19
|
+
const trimmed = name.trim();
|
|
20
|
+
const id = await this.resolveAndReturn(
|
|
21
|
+
context.projectKey,
|
|
22
|
+
context.projectId,
|
|
23
|
+
resolverKey,
|
|
24
|
+
trimmed
|
|
25
|
+
);
|
|
26
|
+
if (id !== void 0) {
|
|
27
|
+
body[inputField] = Number(id);
|
|
28
|
+
} else {
|
|
29
|
+
delete body[inputField];
|
|
30
|
+
warnings.push(
|
|
31
|
+
`Skipped ${inputField} '${trimmed}' — not available in the current project.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async resolveAndReturn(projectKey, projectId, resolverKey, name) {
|
|
36
|
+
const trimmed = name.trim();
|
|
37
|
+
const cached = this.cache.matchValue(projectKey, resolverKey, trimmed);
|
|
38
|
+
if (cached !== void 0) return cached;
|
|
39
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.BUILDS(projectId), {
|
|
40
|
+
search: trimmed
|
|
41
|
+
});
|
|
42
|
+
this.cache.set(projectKey, resolverKey, response);
|
|
43
|
+
return this.cache.matchValue(projectKey, resolverKey, trimmed);
|
|
44
|
+
}
|
|
45
|
+
clearCache(projectKey) {
|
|
46
|
+
this.cache.clear(projectKey);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
BuildResolver
|
|
51
|
+
};
|
|
@@ -39,9 +39,7 @@ class CommonAttributeResolver extends Resolver {
|
|
|
39
39
|
return this.cache.matchValue(projectKey, resolverKey, name);
|
|
40
40
|
}
|
|
41
41
|
async preload(projectKey, projectId) {
|
|
42
|
-
const response = await this.apiClient.get(
|
|
43
|
-
ENDPOINTS.COMMON_ATTRIBUTES(projectId)
|
|
44
|
-
);
|
|
42
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.COMMON_ATTRIBUTES(projectId));
|
|
45
43
|
const attributes = response;
|
|
46
44
|
for (const [key, values] of Object.entries(attributes)) {
|
|
47
45
|
this.cache.set(projectKey, key, values);
|
|
@@ -43,7 +43,7 @@ class ComponentResolver extends Resolver {
|
|
|
43
43
|
async resolveAndReturn(projectKey, projectId, resolverKey, name) {
|
|
44
44
|
const cached = this.cache.matchValue(projectKey, resolverKey, name);
|
|
45
45
|
if (cached !== void 0) return cached;
|
|
46
|
-
const response = await this.apiClient.get(ENDPOINTS.COMPONENTS(projectId), {
|
|
46
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.COMPONENTS(projectId), {
|
|
47
47
|
search: name
|
|
48
48
|
});
|
|
49
49
|
this.cache.set(projectKey, resolverKey, response);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../../config/constants.js";
|
|
2
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
3
|
+
import { Resolver } from "./resolver.js";
|
|
4
|
+
class DefectIdResolver extends Resolver {
|
|
5
|
+
fieldKeys = [
|
|
6
|
+
ResolverKeys.SearchableField.DEFECT_KEY_TO_ID
|
|
7
|
+
];
|
|
8
|
+
apiClient;
|
|
9
|
+
constructor(apiClient) {
|
|
10
|
+
super();
|
|
11
|
+
this.apiClient = apiClient;
|
|
12
|
+
}
|
|
13
|
+
async resolve(inputField, _resolverKey, body, context, warnings) {
|
|
14
|
+
const value = body[inputField];
|
|
15
|
+
if (value == null) return;
|
|
16
|
+
const keys = (Array.isArray(value) ? value : [value]).map(
|
|
17
|
+
(v) => String(v).trim()
|
|
18
|
+
);
|
|
19
|
+
if (keys.length === 0) return;
|
|
20
|
+
const defectMap = await this.resolveAndReturn(context.projectId, keys);
|
|
21
|
+
const resolvedIds = keys.filter((k) => k in defectMap).map((k) => defectMap[k]);
|
|
22
|
+
if (resolvedIds.length > 0) {
|
|
23
|
+
body[inputField] = resolvedIds;
|
|
24
|
+
} else {
|
|
25
|
+
delete body[inputField];
|
|
26
|
+
}
|
|
27
|
+
const unresolvedKeys = keys.filter((k) => !(k in defectMap));
|
|
28
|
+
for (const key of unresolvedKeys) {
|
|
29
|
+
warnings.push(
|
|
30
|
+
`Bug key '${key}' not found in QTM4J defect tracking — skipped.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async resolveAndReturn(projectId, keys) {
|
|
35
|
+
if (keys.length === 0) return {};
|
|
36
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.RESOLVE_DEFECT_IDS(projectId), { keys: keys.join(",") });
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
39
|
+
clearCache(_projectKey) {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
DefectIdResolver
|
|
44
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../../config/constants.js";
|
|
2
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
3
|
+
import { Cache } from "../cache/cache.js";
|
|
4
|
+
import { Resolver } from "./resolver.js";
|
|
5
|
+
class DefectPriorityResolver extends Resolver {
|
|
6
|
+
fieldKeys = [
|
|
7
|
+
ResolverKeys.SearchableField.DEFECT_PRIORITY
|
|
8
|
+
];
|
|
9
|
+
cache;
|
|
10
|
+
apiClient;
|
|
11
|
+
constructor(apiClient, cacheService) {
|
|
12
|
+
super();
|
|
13
|
+
this.apiClient = apiClient;
|
|
14
|
+
this.cache = new Cache(cacheService);
|
|
15
|
+
}
|
|
16
|
+
async resolve(inputField, resolverKey, body, context, warnings) {
|
|
17
|
+
const value = body[inputField];
|
|
18
|
+
if (!Array.isArray(value) || value.length === 0) return;
|
|
19
|
+
const resolvedIds = [];
|
|
20
|
+
for (const item of value) {
|
|
21
|
+
const trimmed = String(item).trim();
|
|
22
|
+
const id = await this.resolveAndReturn(
|
|
23
|
+
context.projectKey,
|
|
24
|
+
context.projectId,
|
|
25
|
+
resolverKey,
|
|
26
|
+
trimmed
|
|
27
|
+
);
|
|
28
|
+
if (id === void 0) {
|
|
29
|
+
warnings.push(
|
|
30
|
+
`Skipped ${inputField} '${trimmed}' — not a recognised defect priority in the current project.`
|
|
31
|
+
);
|
|
32
|
+
} else {
|
|
33
|
+
resolvedIds.push(Number(id));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (resolvedIds.length > 0) {
|
|
37
|
+
body[inputField] = resolvedIds;
|
|
38
|
+
} else {
|
|
39
|
+
delete body[inputField];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async resolveAndReturn(projectKey, projectId, resolverKey, name) {
|
|
43
|
+
const cached = this.cache.matchValue(projectKey, resolverKey, name);
|
|
44
|
+
if (cached !== void 0) return cached;
|
|
45
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.DEFECT_PRIORITIES(projectId), { priorityNames: name });
|
|
46
|
+
this.cache.set(projectKey, resolverKey, response);
|
|
47
|
+
return this.cache.matchValue(projectKey, resolverKey, name);
|
|
48
|
+
}
|
|
49
|
+
clearCache(projectKey) {
|
|
50
|
+
this.cache.clear(projectKey);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
DefectPriorityResolver
|
|
55
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../../config/constants.js";
|
|
2
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
3
|
+
import { Cache } from "../cache/cache.js";
|
|
4
|
+
import { Resolver } from "./resolver.js";
|
|
5
|
+
class DefectStatusResolver extends Resolver {
|
|
6
|
+
fieldKeys = [
|
|
7
|
+
ResolverKeys.SearchableField.DEFECT_STATUS
|
|
8
|
+
];
|
|
9
|
+
cache;
|
|
10
|
+
apiClient;
|
|
11
|
+
constructor(apiClient, cacheService) {
|
|
12
|
+
super();
|
|
13
|
+
this.apiClient = apiClient;
|
|
14
|
+
this.cache = new Cache(cacheService);
|
|
15
|
+
}
|
|
16
|
+
async resolve(inputField, resolverKey, body, context, warnings) {
|
|
17
|
+
const value = body[inputField];
|
|
18
|
+
if (!Array.isArray(value) || value.length === 0) return;
|
|
19
|
+
const resolvedIds = [];
|
|
20
|
+
for (const item of value) {
|
|
21
|
+
const trimmed = String(item).trim();
|
|
22
|
+
const id = await this.resolveAndReturn(
|
|
23
|
+
context.projectKey,
|
|
24
|
+
context.projectId,
|
|
25
|
+
resolverKey,
|
|
26
|
+
trimmed
|
|
27
|
+
);
|
|
28
|
+
if (id === void 0) {
|
|
29
|
+
warnings.push(
|
|
30
|
+
`Skipped ${inputField} '${trimmed}' — not a recognised defect status in the current project.`
|
|
31
|
+
);
|
|
32
|
+
} else {
|
|
33
|
+
resolvedIds.push(Number(id));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (resolvedIds.length > 0) {
|
|
37
|
+
body[inputField] = resolvedIds;
|
|
38
|
+
} else {
|
|
39
|
+
delete body[inputField];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async resolveAndReturn(projectKey, projectId, resolverKey, name) {
|
|
43
|
+
const cached = this.cache.matchValue(projectKey, resolverKey, name);
|
|
44
|
+
if (cached !== void 0) return cached;
|
|
45
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.DEFECT_STATUSES(projectId), { statusNames: name });
|
|
46
|
+
this.cache.set(projectKey, resolverKey, response);
|
|
47
|
+
return this.cache.matchValue(projectKey, resolverKey, name);
|
|
48
|
+
}
|
|
49
|
+
clearCache(projectKey) {
|
|
50
|
+
this.cache.clear(projectKey);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
DefectStatusResolver
|
|
55
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../../config/constants.js";
|
|
2
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
3
|
+
import { Cache } from "../cache/cache.js";
|
|
4
|
+
import { Resolver } from "./resolver.js";
|
|
5
|
+
class EnvironmentResolver extends Resolver {
|
|
6
|
+
fieldKeys = [
|
|
7
|
+
ResolverKeys.SearchableField.ENVIRONMENT
|
|
8
|
+
];
|
|
9
|
+
cache;
|
|
10
|
+
apiClient;
|
|
11
|
+
constructor(apiClient, cacheService) {
|
|
12
|
+
super();
|
|
13
|
+
this.apiClient = apiClient;
|
|
14
|
+
this.cache = new Cache(cacheService);
|
|
15
|
+
}
|
|
16
|
+
async resolve(inputField, resolverKey, body, context, warnings) {
|
|
17
|
+
const name = body[inputField];
|
|
18
|
+
if (name == null || typeof name === "number") return;
|
|
19
|
+
const trimmed = name.trim();
|
|
20
|
+
const id = await this.resolveAndReturn(
|
|
21
|
+
context.projectKey,
|
|
22
|
+
context.projectId,
|
|
23
|
+
resolverKey,
|
|
24
|
+
trimmed
|
|
25
|
+
);
|
|
26
|
+
if (id === void 0) {
|
|
27
|
+
delete body[inputField];
|
|
28
|
+
warnings.push(
|
|
29
|
+
`Skipped ${inputField} '${trimmed}' — not available in the current project.`
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
body[inputField] = Number(id);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async resolveAndReturn(projectKey, projectId, resolverKey, name) {
|
|
36
|
+
const trimmed = name.trim();
|
|
37
|
+
const cached = this.cache.matchValue(projectKey, resolverKey, trimmed);
|
|
38
|
+
if (cached !== void 0) return cached;
|
|
39
|
+
const response = await this.apiClient.skipAnalytics().get(ENDPOINTS.ENVIRONMENTS(projectId), {
|
|
40
|
+
search: trimmed
|
|
41
|
+
});
|
|
42
|
+
this.cache.set(projectKey, resolverKey, response);
|
|
43
|
+
return this.cache.matchValue(projectKey, resolverKey, trimmed);
|
|
44
|
+
}
|
|
45
|
+
clearCache(projectKey) {
|
|
46
|
+
this.cache.clear(projectKey);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
EnvironmentResolver
|
|
51
|
+
};
|