@rbaileysr/zephyr-managed-api 1.3.3 → 1.3.4
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/README.md +69 -53
- package/dist/README.md +69 -53
- package/dist/groups/All.d.ts.map +1 -1
- package/dist/groups/Private/PrivateAttachments.d.ts +2 -2
- package/dist/groups/Private/PrivateAttachments.js +2 -2
- package/dist/groups/Private/PrivateComments.d.ts +1 -1
- package/dist/groups/Private/PrivateComments.js +1 -1
- package/dist/groups/Private/PrivateConfig.d.ts +47 -0
- package/dist/groups/Private/PrivateConfig.d.ts.map +1 -1
- package/dist/groups/Private/PrivateConfig.js +100 -0
- package/dist/groups/Private/PrivateVersionControl.d.ts +66 -5
- package/dist/groups/Private/PrivateVersionControl.d.ts.map +1 -1
- package/dist/groups/Private/PrivateVersionControl.js +259 -4
- package/dist/groups/TestCase.d.ts +1 -1
- package/dist/groups/TestCase.js +1 -1
- package/dist/package.json +1 -1
- package/dist/types.d.ts +80 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ⚠️ WARNING: These methods use private APIs that are not officially supported.
|
|
9
9
|
*/
|
|
10
|
-
import type { PrivateApiCredentials, GetTestCaseIssueLinksRequest, GetTestCaseWebLinksRequest, GetTestCaseTestScriptRequest, GetTestCaseTestStepsRequest, IssueLinkList, WebLinkList, TestScript, TestStepsList } from '../../types';
|
|
10
|
+
import type { PrivateApiCredentials, GetTestCaseIssueLinksRequest, GetTestCaseWebLinksRequest, GetTestCaseTestScriptRequest, GetTestCaseTestStepsRequest, GetTestExecutionStepIssueLinksRequest, CreateTestExecutionStepIssueLinkRequest, CreateTestExecutionStepIssueLinkResponse, TestExecutionStepIssueLinkList, IssueLinkList, WebLinkList, TestScript, TestStepsList } from '../../types';
|
|
11
11
|
import { PrivateBase } from './PrivateBase';
|
|
12
12
|
import type { ZephyrApiConnection } from '../../index';
|
|
13
13
|
export declare class PrivateVersionControl extends PrivateBase {
|
|
@@ -25,7 +25,7 @@ export declare class PrivateVersionControl extends PrivateBase {
|
|
|
25
25
|
* @param request - Get issue links request
|
|
26
26
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
|
|
27
27
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
28
|
-
* @param request.version - Optional version number (
|
|
28
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
29
29
|
* @returns Array of issue links matching the public API format
|
|
30
30
|
* @throws {BadRequestError} If the request is invalid
|
|
31
31
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -48,7 +48,7 @@ export declare class PrivateVersionControl extends PrivateBase {
|
|
|
48
48
|
* @param request - Get web links request
|
|
49
49
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
|
|
50
50
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
51
|
-
* @param request.version - Optional version number (
|
|
51
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
52
52
|
* @returns Array of web links matching the public API format
|
|
53
53
|
* @throws {BadRequestError} If the request is invalid
|
|
54
54
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -71,7 +71,7 @@ export declare class PrivateVersionControl extends PrivateBase {
|
|
|
71
71
|
* @param request - Get test script request
|
|
72
72
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1')
|
|
73
73
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
74
|
-
* @param request.version - Optional version number (
|
|
74
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
75
75
|
* @returns Test script matching the public API format, or null if no test script exists
|
|
76
76
|
* @throws {BadRequestError} If the request is invalid
|
|
77
77
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -94,7 +94,7 @@ export declare class PrivateVersionControl extends PrivateBase {
|
|
|
94
94
|
* @param request - Get test steps request
|
|
95
95
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1')
|
|
96
96
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
97
|
-
* @param request.version - Optional version number (
|
|
97
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
98
98
|
* @returns Test steps list matching the public API format
|
|
99
99
|
* @throws {BadRequestError} If the request is invalid
|
|
100
100
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -104,5 +104,66 @@ export declare class PrivateVersionControl extends PrivateBase {
|
|
|
104
104
|
* @throws {UnexpectedError} If test case cannot be retrieved
|
|
105
105
|
*/
|
|
106
106
|
getTestCaseTestSteps(credentials: PrivateApiCredentials, request: GetTestCaseTestStepsRequest): Promise<TestStepsList>;
|
|
107
|
+
/**
|
|
108
|
+
* Map LinkType to numeric typeId for private API
|
|
109
|
+
*/
|
|
110
|
+
private mapLinkTypeToTypeId;
|
|
111
|
+
/**
|
|
112
|
+
* Map numeric typeId to LinkType for private API
|
|
113
|
+
*/
|
|
114
|
+
private mapTypeIdToLinkType;
|
|
115
|
+
/**
|
|
116
|
+
* Get issue links for a test execution step using private API
|
|
117
|
+
*
|
|
118
|
+
* Retrieves all issue links associated with a specific test execution step. This is useful for
|
|
119
|
+
* migration scenarios where you need to extract issue links from a source test execution and
|
|
120
|
+
* recreate them in a target instance.
|
|
121
|
+
*
|
|
122
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
123
|
+
* The endpoint may change or be removed at any time without notice.
|
|
124
|
+
*
|
|
125
|
+
* @param credentials - Private API credentials
|
|
126
|
+
* @param request - Get issue links request
|
|
127
|
+
* @param request.testExecutionKey - Test execution key (e.g., 'PROJ-E1')
|
|
128
|
+
* @param request.stepIndex - Zero-based index of the test execution step
|
|
129
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
130
|
+
* @returns List of issue links for the test execution step
|
|
131
|
+
* @throws {BadRequestError} If the request is invalid
|
|
132
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
133
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
134
|
+
* @throws {NotFoundError} If the test execution or step is not found
|
|
135
|
+
* @throws {ServerError} If the server returns an error
|
|
136
|
+
* @throws {UnexpectedError} If an unexpected error occurs
|
|
137
|
+
*/
|
|
138
|
+
getTestExecutionStepIssueLinks(credentials: PrivateApiCredentials, request: GetTestExecutionStepIssueLinksRequest): Promise<TestExecutionStepIssueLinkList>;
|
|
139
|
+
/**
|
|
140
|
+
* Map system key to LinkType
|
|
141
|
+
*/
|
|
142
|
+
private mapSystemKeyToLinkType;
|
|
143
|
+
/**
|
|
144
|
+
* Create an issue link for a test execution step using private API
|
|
145
|
+
*
|
|
146
|
+
* Creates a link between a test execution step and a Jira issue. The link type can be COVERAGE, BLOCKS, or RELATED.
|
|
147
|
+
* This functionality is not available in the public API.
|
|
148
|
+
*
|
|
149
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
150
|
+
* The endpoint may change or be removed at any time without notice.
|
|
151
|
+
*
|
|
152
|
+
* @param credentials - Private API credentials
|
|
153
|
+
* @param request - Create issue link request
|
|
154
|
+
* @param request.testExecutionKey - Test execution key (e.g., 'PROJ-E1')
|
|
155
|
+
* @param request.stepIndex - Zero-based index of the test execution step
|
|
156
|
+
* @param request.issueId - Jira issue ID (numeric)
|
|
157
|
+
* @param request.type - Link type: 'COVERAGE', 'BLOCKS', or 'RELATED' (optional, defaults to 'COVERAGE')
|
|
158
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
159
|
+
* @returns Created link response with ID
|
|
160
|
+
* @throws {BadRequestError} If the request is invalid
|
|
161
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
162
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
163
|
+
* @throws {NotFoundError} If the test execution or step is not found
|
|
164
|
+
* @throws {ServerError} If the server returns an error
|
|
165
|
+
* @throws {UnexpectedError} If test execution ID cannot be looked up
|
|
166
|
+
*/
|
|
167
|
+
createTestExecutionStepIssueLink(credentials: PrivateApiCredentials, request: CreateTestExecutionStepIssueLinkRequest): Promise<CreateTestExecutionStepIssueLinkResponse>;
|
|
107
168
|
}
|
|
108
169
|
//# sourceMappingURL=PrivateVersionControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateVersionControl.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateVersionControl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,
|
|
1
|
+
{"version":3,"file":"PrivateVersionControl.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateVersionControl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,qCAAqC,EACrC,uCAAuC,EACvC,wCAAwC,EACxC,8BAA8B,EAC9B,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EAMb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAqEvD,qBAAa,qBAAsB,SAAQ,WAAW;gBACzC,aAAa,CAAC,EAAE,mBAAmB;IAI/C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,qBAAqB,CAC1B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,aAAa,CAAC;IA2GzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,mBAAmB,CACxB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,0BAA0B,GACjC,OAAO,CAAC,WAAW,CAAC;IA2GvB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,qBAAqB,CAC1B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAgH7B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,oBAAoB,CACzB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,aAAa,CAAC;IAiIzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,8BAA8B,CACnC,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,qCAAqC,GAC5C,OAAO,CAAC,8BAA8B,CAAC;IAiF1C;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,gCAAgC,CACrC,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,uCAAuC,GAC9C,OAAO,CAAC,wCAAwC,CAAC;CA+IpD"}
|
|
@@ -20,7 +20,7 @@ export class PrivateVersionControl extends PrivateBase {
|
|
|
20
20
|
* @param request - Get issue links request
|
|
21
21
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
|
|
22
22
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
23
|
-
* @param request.version - Optional version number (
|
|
23
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
24
24
|
* @returns Array of issue links matching the public API format
|
|
25
25
|
* @throws {BadRequestError} If the request is invalid
|
|
26
26
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -125,7 +125,7 @@ export class PrivateVersionControl extends PrivateBase {
|
|
|
125
125
|
* @param request - Get web links request
|
|
126
126
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
|
|
127
127
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
128
|
-
* @param request.version - Optional version number (
|
|
128
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
129
129
|
* @returns Array of web links matching the public API format
|
|
130
130
|
* @throws {BadRequestError} If the request is invalid
|
|
131
131
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -230,7 +230,7 @@ export class PrivateVersionControl extends PrivateBase {
|
|
|
230
230
|
* @param request - Get test script request
|
|
231
231
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1')
|
|
232
232
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
233
|
-
* @param request.version - Optional version number (
|
|
233
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
234
234
|
* @returns Test script matching the public API format, or null if no test script exists
|
|
235
235
|
* @throws {BadRequestError} If the request is invalid
|
|
236
236
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -339,7 +339,7 @@ export class PrivateVersionControl extends PrivateBase {
|
|
|
339
339
|
* @param request - Get test steps request
|
|
340
340
|
* @param request.testCaseKey - Test case key (e.g., 'PROJ-T1')
|
|
341
341
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
342
|
-
* @param request.version - Optional version number (
|
|
342
|
+
* @param request.version - Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version). If not provided, uses the latest version.
|
|
343
343
|
* @returns Test steps list matching the public API format
|
|
344
344
|
* @throws {BadRequestError} If the request is invalid
|
|
345
345
|
* @throws {UnauthorizedError} If authentication fails
|
|
@@ -451,4 +451,259 @@ export class PrivateVersionControl extends PrivateBase {
|
|
|
451
451
|
throw new UnexpectedError('Unexpected error while getting test case test steps', error);
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Map LinkType to numeric typeId for private API
|
|
456
|
+
*/
|
|
457
|
+
mapLinkTypeToTypeId(type) {
|
|
458
|
+
switch (type) {
|
|
459
|
+
case 'COVERAGE':
|
|
460
|
+
return 1;
|
|
461
|
+
case 'BLOCKS':
|
|
462
|
+
return 2;
|
|
463
|
+
case 'RELATED':
|
|
464
|
+
return 3;
|
|
465
|
+
default:
|
|
466
|
+
return 1; // Default to COVERAGE
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Map numeric typeId to LinkType for private API
|
|
471
|
+
*/
|
|
472
|
+
mapTypeIdToLinkType(typeId) {
|
|
473
|
+
switch (typeId) {
|
|
474
|
+
case 1:
|
|
475
|
+
return 'COVERAGE';
|
|
476
|
+
case 2:
|
|
477
|
+
return 'BLOCKS';
|
|
478
|
+
case 3:
|
|
479
|
+
return 'RELATED';
|
|
480
|
+
default:
|
|
481
|
+
return 'COVERAGE'; // Default to COVERAGE
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Get issue links for a test execution step using private API
|
|
486
|
+
*
|
|
487
|
+
* Retrieves all issue links associated with a specific test execution step. This is useful for
|
|
488
|
+
* migration scenarios where you need to extract issue links from a source test execution and
|
|
489
|
+
* recreate them in a target instance.
|
|
490
|
+
*
|
|
491
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
492
|
+
* The endpoint may change or be removed at any time without notice.
|
|
493
|
+
*
|
|
494
|
+
* @param credentials - Private API credentials
|
|
495
|
+
* @param request - Get issue links request
|
|
496
|
+
* @param request.testExecutionKey - Test execution key (e.g., 'PROJ-E1')
|
|
497
|
+
* @param request.stepIndex - Zero-based index of the test execution step
|
|
498
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
499
|
+
* @returns List of issue links for the test execution step
|
|
500
|
+
* @throws {BadRequestError} If the request is invalid
|
|
501
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
502
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
503
|
+
* @throws {NotFoundError} If the test execution or step is not found
|
|
504
|
+
* @throws {ServerError} If the server returns an error
|
|
505
|
+
* @throws {UnexpectedError} If an unexpected error occurs
|
|
506
|
+
*/
|
|
507
|
+
async getTestExecutionStepIssueLinks(credentials, request) {
|
|
508
|
+
// Get Context JWT
|
|
509
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
510
|
+
// Fetch test execution with traceLinks in testScriptResults
|
|
511
|
+
const url = `${this.privateApiBaseUrl}/testresult/${request.testExecutionKey}?fields=testScriptResults(id,index,traceLinks(id,type(id,systemKey),issueId)),attachments&itemId=${request.testExecutionKey}`;
|
|
512
|
+
const headers = {
|
|
513
|
+
accept: 'application/json',
|
|
514
|
+
authorization: `JWT ${contextJwt}`,
|
|
515
|
+
'jira-project-id': String(request.projectId),
|
|
516
|
+
};
|
|
517
|
+
try {
|
|
518
|
+
const response = await fetch(url, {
|
|
519
|
+
method: 'GET',
|
|
520
|
+
headers,
|
|
521
|
+
});
|
|
522
|
+
if (!response.ok) {
|
|
523
|
+
if (response.status === 404) {
|
|
524
|
+
throw new NotFoundError(`Test execution with key '${request.testExecutionKey}' not found.`);
|
|
525
|
+
}
|
|
526
|
+
if (response.status === 401) {
|
|
527
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
528
|
+
}
|
|
529
|
+
if (response.status === 403) {
|
|
530
|
+
throw new ForbiddenError('Insufficient permissions to get test execution step issue links.');
|
|
531
|
+
}
|
|
532
|
+
throw new ServerError(`Failed to get test execution step issue links. Status: ${response.status}`, response.status, response.statusText);
|
|
533
|
+
}
|
|
534
|
+
const executionData = (await response.json());
|
|
535
|
+
const steps = executionData.testScriptResults || [];
|
|
536
|
+
if (request.stepIndex < 0 || request.stepIndex >= steps.length) {
|
|
537
|
+
throw new NotFoundError(`Test execution step at index ${request.stepIndex} not found in test execution '${request.testExecutionKey}'. Test execution has ${steps.length} step(s).`);
|
|
538
|
+
}
|
|
539
|
+
const step = steps[request.stepIndex];
|
|
540
|
+
const traceLinks = step.traceLinks || [];
|
|
541
|
+
// Transform private API response to migration-friendly format
|
|
542
|
+
return traceLinks.map((link) => ({
|
|
543
|
+
id: link.id,
|
|
544
|
+
issueId: link.issueId,
|
|
545
|
+
type: this.mapSystemKeyToLinkType(link.type.systemKey),
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
catch (error) {
|
|
549
|
+
if (error instanceof NotFoundError ||
|
|
550
|
+
error instanceof UnauthorizedError ||
|
|
551
|
+
error instanceof ForbiddenError ||
|
|
552
|
+
error instanceof ServerError ||
|
|
553
|
+
error instanceof UnexpectedError) {
|
|
554
|
+
throw error;
|
|
555
|
+
}
|
|
556
|
+
throw new UnexpectedError('Unexpected error while getting test execution step issue links', error);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Map system key to LinkType
|
|
561
|
+
*/
|
|
562
|
+
mapSystemKeyToLinkType(systemKey) {
|
|
563
|
+
switch (systemKey.toUpperCase()) {
|
|
564
|
+
case 'COVERAGE':
|
|
565
|
+
return 'COVERAGE';
|
|
566
|
+
case 'BLOCKS':
|
|
567
|
+
return 'BLOCKS';
|
|
568
|
+
case 'RELATED':
|
|
569
|
+
return 'RELATED';
|
|
570
|
+
default:
|
|
571
|
+
return 'COVERAGE'; // Default to COVERAGE
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Create an issue link for a test execution step using private API
|
|
576
|
+
*
|
|
577
|
+
* Creates a link between a test execution step and a Jira issue. The link type can be COVERAGE, BLOCKS, or RELATED.
|
|
578
|
+
* This functionality is not available in the public API.
|
|
579
|
+
*
|
|
580
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
581
|
+
* The endpoint may change or be removed at any time without notice.
|
|
582
|
+
*
|
|
583
|
+
* @param credentials - Private API credentials
|
|
584
|
+
* @param request - Create issue link request
|
|
585
|
+
* @param request.testExecutionKey - Test execution key (e.g., 'PROJ-E1')
|
|
586
|
+
* @param request.stepIndex - Zero-based index of the test execution step
|
|
587
|
+
* @param request.issueId - Jira issue ID (numeric)
|
|
588
|
+
* @param request.type - Link type: 'COVERAGE', 'BLOCKS', or 'RELATED' (optional, defaults to 'COVERAGE')
|
|
589
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
590
|
+
* @returns Created link response with ID
|
|
591
|
+
* @throws {BadRequestError} If the request is invalid
|
|
592
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
593
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
594
|
+
* @throws {NotFoundError} If the test execution or step is not found
|
|
595
|
+
* @throws {ServerError} If the server returns an error
|
|
596
|
+
* @throws {UnexpectedError} If test execution ID cannot be looked up
|
|
597
|
+
*/
|
|
598
|
+
async createTestExecutionStepIssueLink(credentials, request) {
|
|
599
|
+
// Get Context JWT
|
|
600
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
601
|
+
// Step 1: Get test execution to find testResultId (numeric ID)
|
|
602
|
+
let testResultId;
|
|
603
|
+
if (this.testExecutionGroup) {
|
|
604
|
+
try {
|
|
605
|
+
const testExecution = await this.testExecutionGroup.getTestExecution({
|
|
606
|
+
testExecutionIdOrKey: request.testExecutionKey,
|
|
607
|
+
});
|
|
608
|
+
testResultId = testExecution.id;
|
|
609
|
+
}
|
|
610
|
+
catch (error) {
|
|
611
|
+
if (error instanceof NotFoundError) {
|
|
612
|
+
throw new NotFoundError(`Test execution with key '${request.testExecutionKey}' not found.`);
|
|
613
|
+
}
|
|
614
|
+
throw new UnexpectedError(`Failed to look up test execution ID from key '${request.testExecutionKey}'. Ensure Zephyr Connector is configured.`, error);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
throw new UnexpectedError('Cannot look up test execution ID from key. This method requires Zephyr Connector to be configured. Use createZephyrApi() with an API Connection.');
|
|
619
|
+
}
|
|
620
|
+
// Step 2: Get test execution steps to find testScriptResultId from stepIndex
|
|
621
|
+
const url = `${this.privateApiBaseUrl}/testresult/${request.testExecutionKey}?fields=testScriptResults(id,index),attachments&itemId=${request.testExecutionKey}`;
|
|
622
|
+
const headers = {
|
|
623
|
+
accept: 'application/json',
|
|
624
|
+
authorization: `JWT ${contextJwt}`,
|
|
625
|
+
'jira-project-id': String(request.projectId),
|
|
626
|
+
};
|
|
627
|
+
let testScriptResultId;
|
|
628
|
+
try {
|
|
629
|
+
const response = await fetch(url, {
|
|
630
|
+
method: 'GET',
|
|
631
|
+
headers,
|
|
632
|
+
});
|
|
633
|
+
if (!response.ok) {
|
|
634
|
+
if (response.status === 404) {
|
|
635
|
+
throw new NotFoundError(`Test execution with key '${request.testExecutionKey}' not found.`);
|
|
636
|
+
}
|
|
637
|
+
throw new ServerError(`Failed to get test execution steps. Status: ${response.status}`, response.status, response.statusText);
|
|
638
|
+
}
|
|
639
|
+
const executionData = (await response.json());
|
|
640
|
+
const steps = executionData.testScriptResults || [];
|
|
641
|
+
if (request.stepIndex < 0 || request.stepIndex >= steps.length) {
|
|
642
|
+
throw new NotFoundError(`Test execution step at index ${request.stepIndex} not found in test execution '${request.testExecutionKey}'. Test execution has ${steps.length} step(s).`);
|
|
643
|
+
}
|
|
644
|
+
testScriptResultId = steps[request.stepIndex].id;
|
|
645
|
+
}
|
|
646
|
+
catch (error) {
|
|
647
|
+
if (error instanceof NotFoundError ||
|
|
648
|
+
error instanceof ServerError ||
|
|
649
|
+
error instanceof UnexpectedError) {
|
|
650
|
+
throw error;
|
|
651
|
+
}
|
|
652
|
+
throw new UnexpectedError('Unexpected error while getting test execution steps', error);
|
|
653
|
+
}
|
|
654
|
+
// Step 3: Create the issue link using bulk endpoint
|
|
655
|
+
const typeId = this.mapLinkTypeToTypeId(request.type);
|
|
656
|
+
const bulkUrl = `${this.privateApiBaseUrl}/tracelink/testresult/bulk/create`;
|
|
657
|
+
const bulkHeaders = {
|
|
658
|
+
'Content-Type': 'application/json',
|
|
659
|
+
authorization: `JWT ${contextJwt}`,
|
|
660
|
+
'jira-project-id': String(request.projectId),
|
|
661
|
+
};
|
|
662
|
+
const requestBody = [
|
|
663
|
+
{
|
|
664
|
+
testResultId,
|
|
665
|
+
issueId: String(request.issueId),
|
|
666
|
+
testScriptResultId,
|
|
667
|
+
typeId,
|
|
668
|
+
},
|
|
669
|
+
];
|
|
670
|
+
try {
|
|
671
|
+
const response = await fetch(bulkUrl, {
|
|
672
|
+
method: 'POST',
|
|
673
|
+
headers: bulkHeaders,
|
|
674
|
+
body: JSON.stringify(requestBody),
|
|
675
|
+
});
|
|
676
|
+
if (!response.ok) {
|
|
677
|
+
if (response.status === 400) {
|
|
678
|
+
throw new BadRequestError('Invalid request parameters for creating test execution step issue link.');
|
|
679
|
+
}
|
|
680
|
+
if (response.status === 401) {
|
|
681
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
682
|
+
}
|
|
683
|
+
if (response.status === 403) {
|
|
684
|
+
throw new ForbiddenError('Insufficient permissions to create test execution step issue link.');
|
|
685
|
+
}
|
|
686
|
+
if (response.status === 404) {
|
|
687
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' or step at index ${request.stepIndex} not found.`);
|
|
688
|
+
}
|
|
689
|
+
throw new ServerError(`Failed to create test execution step issue link. Status: ${response.status}`, response.status, response.statusText);
|
|
690
|
+
}
|
|
691
|
+
const results = (await response.json());
|
|
692
|
+
if (results.length === 0) {
|
|
693
|
+
throw new UnexpectedError('No link ID returned from API response.');
|
|
694
|
+
}
|
|
695
|
+
return results[0];
|
|
696
|
+
}
|
|
697
|
+
catch (error) {
|
|
698
|
+
if (error instanceof BadRequestError ||
|
|
699
|
+
error instanceof UnauthorizedError ||
|
|
700
|
+
error instanceof ForbiddenError ||
|
|
701
|
+
error instanceof NotFoundError ||
|
|
702
|
+
error instanceof ServerError ||
|
|
703
|
+
error instanceof UnexpectedError) {
|
|
704
|
+
throw error;
|
|
705
|
+
}
|
|
706
|
+
throw new UnexpectedError('Unexpected error while creating test execution step issue link', error);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
454
709
|
}
|
|
@@ -183,7 +183,7 @@ export declare class TestCaseGroup {
|
|
|
183
183
|
*
|
|
184
184
|
* @param options - Get version options
|
|
185
185
|
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
186
|
-
* @param options.version - The version number (1-based,
|
|
186
|
+
* @param options.version - The version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version)
|
|
187
187
|
* @returns Test case object for the specified version
|
|
188
188
|
*
|
|
189
189
|
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/#tag/Test-Cases/operation/getTestCaseVersion Official API Documentation}
|
package/dist/groups/TestCase.js
CHANGED
|
@@ -232,7 +232,7 @@ export class TestCaseGroup {
|
|
|
232
232
|
*
|
|
233
233
|
* @param options - Get version options
|
|
234
234
|
* @param options.testCaseKey - The test case key (e.g., 'PROJ-T1')
|
|
235
|
-
* @param options.version - The version number (1-based,
|
|
235
|
+
* @param options.version - The version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version)
|
|
236
236
|
* @returns Test case object for the specified version
|
|
237
237
|
*
|
|
238
238
|
* @see {@link https://support.smartbear.com/zephyr-scale-cloud/api-docs/#tag/Test-Cases/operation/getTestCaseVersion Official API Documentation}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbaileysr/zephyr-managed-api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Managed API wrapper for Zephyr Cloud REST API v2 - Comprehensive type-safe access to all Zephyr API endpoints for ScriptRunner Connect",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/dist/types.d.ts
CHANGED
|
@@ -1529,9 +1529,8 @@ export interface GetTestCaseCommentsRequest {
|
|
|
1529
1529
|
testCaseKey: string;
|
|
1530
1530
|
projectId: number;
|
|
1531
1531
|
/**
|
|
1532
|
-
* Optional version number (
|
|
1533
|
-
* If not provided or undefined, uses the latest version (
|
|
1534
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
1532
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
1533
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
1535
1534
|
*/
|
|
1536
1535
|
version?: number;
|
|
1537
1536
|
}
|
|
@@ -1578,9 +1577,8 @@ export interface GetTestCaseAttachmentsRequest {
|
|
|
1578
1577
|
testCaseKey: string;
|
|
1579
1578
|
projectId: number;
|
|
1580
1579
|
/**
|
|
1581
|
-
* Optional version number (
|
|
1582
|
-
* If not provided or undefined, uses the latest version (
|
|
1583
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
1580
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
1581
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
1584
1582
|
*/
|
|
1585
1583
|
version?: number;
|
|
1586
1584
|
}
|
|
@@ -1592,9 +1590,8 @@ export interface DownloadAttachmentRequest {
|
|
|
1592
1590
|
projectId: number;
|
|
1593
1591
|
attachmentId: string;
|
|
1594
1592
|
/**
|
|
1595
|
-
* Optional version number (
|
|
1596
|
-
* If not provided or undefined, uses the latest version (
|
|
1597
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
1593
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
1594
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
1598
1595
|
*/
|
|
1599
1596
|
version?: number;
|
|
1600
1597
|
}
|
|
@@ -1966,6 +1963,33 @@ export interface UpdateDataSetResponse {
|
|
|
1966
1963
|
export interface GetDataSetsRequest {
|
|
1967
1964
|
projectId: number;
|
|
1968
1965
|
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Config type for archive/unarchive operations
|
|
1968
|
+
*/
|
|
1969
|
+
export type ConfigType = 'Environment' | 'Iteration';
|
|
1970
|
+
/**
|
|
1971
|
+
* Archive config request for private API
|
|
1972
|
+
*/
|
|
1973
|
+
export interface ArchiveConfigRequest {
|
|
1974
|
+
/**
|
|
1975
|
+
* Type of config item: 'Environment' or 'Iteration'
|
|
1976
|
+
*/
|
|
1977
|
+
type: ConfigType;
|
|
1978
|
+
/**
|
|
1979
|
+
* Numeric ID of the environment or iteration to archive
|
|
1980
|
+
*/
|
|
1981
|
+
id: number;
|
|
1982
|
+
/**
|
|
1983
|
+
* Jira project ID (numeric, not the project key)
|
|
1984
|
+
*/
|
|
1985
|
+
projectId: number;
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Archive config response for private API
|
|
1989
|
+
*/
|
|
1990
|
+
export interface ArchiveConfigResponse {
|
|
1991
|
+
id: number;
|
|
1992
|
+
}
|
|
1969
1993
|
/**
|
|
1970
1994
|
* Get test case issue links request for private API
|
|
1971
1995
|
*/
|
|
@@ -1973,9 +1997,8 @@ export interface GetTestCaseIssueLinksRequest {
|
|
|
1973
1997
|
testCaseKey: string;
|
|
1974
1998
|
projectId: number;
|
|
1975
1999
|
/**
|
|
1976
|
-
* Optional version number (
|
|
1977
|
-
* If not provided or undefined, uses the latest version (
|
|
1978
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
2000
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
2001
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
1979
2002
|
*/
|
|
1980
2003
|
version?: number;
|
|
1981
2004
|
}
|
|
@@ -1986,9 +2009,8 @@ export interface GetTestCaseWebLinksRequest {
|
|
|
1986
2009
|
testCaseKey: string;
|
|
1987
2010
|
projectId: number;
|
|
1988
2011
|
/**
|
|
1989
|
-
* Optional version number (
|
|
1990
|
-
* If not provided or undefined, uses the latest version (
|
|
1991
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
2012
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
2013
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
1992
2014
|
*/
|
|
1993
2015
|
version?: number;
|
|
1994
2016
|
}
|
|
@@ -1999,9 +2021,8 @@ export interface GetTestCaseTestScriptRequest {
|
|
|
1999
2021
|
testCaseKey: string;
|
|
2000
2022
|
projectId: number;
|
|
2001
2023
|
/**
|
|
2002
|
-
* Optional version number (
|
|
2003
|
-
* If not provided or undefined, uses the latest version (
|
|
2004
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
2024
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
2025
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
2005
2026
|
*/
|
|
2006
2027
|
version?: number;
|
|
2007
2028
|
}
|
|
@@ -2012,10 +2033,48 @@ export interface GetTestCaseTestStepsRequest {
|
|
|
2012
2033
|
testCaseKey: string;
|
|
2013
2034
|
projectId: number;
|
|
2014
2035
|
/**
|
|
2015
|
-
* Optional version number (
|
|
2016
|
-
* If not provided or undefined, uses the latest version (
|
|
2017
|
-
* Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
|
|
2036
|
+
* Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
|
|
2037
|
+
* If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
|
|
2018
2038
|
*/
|
|
2019
2039
|
version?: number;
|
|
2020
2040
|
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Create test execution step issue link request for private API
|
|
2043
|
+
*/
|
|
2044
|
+
export interface CreateTestExecutionStepIssueLinkRequest {
|
|
2045
|
+
testExecutionKey: string;
|
|
2046
|
+
stepIndex: number;
|
|
2047
|
+
/**
|
|
2048
|
+
* Jira issue ID (can be provided as number or string, will be converted to string for API)
|
|
2049
|
+
*/
|
|
2050
|
+
issueId: number | string;
|
|
2051
|
+
type: LinkType;
|
|
2052
|
+
projectId: number;
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2055
|
+
* Create test execution step issue link response for private API
|
|
2056
|
+
*/
|
|
2057
|
+
export interface CreateTestExecutionStepIssueLinkResponse {
|
|
2058
|
+
id: number;
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Get test execution step issue links request for private API
|
|
2062
|
+
*/
|
|
2063
|
+
export interface GetTestExecutionStepIssueLinksRequest {
|
|
2064
|
+
testExecutionKey: string;
|
|
2065
|
+
stepIndex: number;
|
|
2066
|
+
projectId: number;
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Test execution step issue link (from private API response)
|
|
2070
|
+
*/
|
|
2071
|
+
export interface TestExecutionStepIssueLink {
|
|
2072
|
+
id: number;
|
|
2073
|
+
issueId: string;
|
|
2074
|
+
type: LinkType;
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Test execution step issue link list
|
|
2078
|
+
*/
|
|
2079
|
+
export type TestExecutionStepIssueLinkList = TestExecutionStepIssueLink[];
|
|
2021
2080
|
//# sourceMappingURL=types.d.ts.map
|