@rbaileysr/zephyr-managed-api 1.3.5 → 1.3.7
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 +116 -4
- package/dist/README.md +116 -4
- package/dist/groups/All.d.ts +5 -5
- package/dist/groups/All.d.ts.map +1 -1
- package/dist/groups/Environment.d.ts +3 -3
- package/dist/groups/Environment.d.ts.map +1 -1
- package/dist/groups/Environment.js +1 -1
- package/dist/groups/Folder.d.ts +3 -3
- package/dist/groups/Folder.d.ts.map +1 -1
- package/dist/groups/Folder.js +1 -1
- package/dist/groups/Priority.d.ts +3 -3
- package/dist/groups/Priority.d.ts.map +1 -1
- package/dist/groups/Priority.js +1 -1
- package/dist/groups/Private/PrivateConfig.d.ts +26 -10
- package/dist/groups/Private/PrivateConfig.d.ts.map +1 -1
- package/dist/groups/Private/PrivateConfig.js +36 -12
- package/dist/groups/Private/PrivateIterationData.d.ts +157 -0
- package/dist/groups/Private/PrivateIterationData.d.ts.map +1 -0
- package/dist/groups/Private/PrivateIterationData.js +364 -0
- package/dist/groups/Private.d.ts +6 -0
- package/dist/groups/Private.d.ts.map +1 -1
- package/dist/groups/Private.js +2 -0
- package/dist/groups/Status.d.ts +3 -3
- package/dist/groups/Status.d.ts.map +1 -1
- package/dist/groups/Status.js +1 -1
- package/dist/groups/TestExecution.d.ts +4 -2
- package/dist/groups/TestExecution.d.ts.map +1 -1
- package/dist/groups/TestExecution.js +6 -2
- package/dist/package.json +1 -1
- package/dist/types.d.ts +101 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -16,46 +16,62 @@ export class PrivateConfig extends PrivateBase {
|
|
|
16
16
|
this.DataSets = new PrivateDataSets(apiConnection);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Archive a config item
|
|
19
|
+
* Archive a config item using private API
|
|
20
20
|
*
|
|
21
|
-
* Archives
|
|
21
|
+
* Archives a config item (Environment, Iteration, or Status) by setting its `isArchived` flag to `true`.
|
|
22
|
+
*
|
|
23
|
+
* Supported config types:
|
|
24
|
+
* - 'Environment' - Archive an environment
|
|
25
|
+
* - 'Iteration' - Archive an iteration
|
|
26
|
+
* - 'TestCaseStatus' - Archive a test case status
|
|
27
|
+
* - 'TestPlanStatus' - Archive a test plan status
|
|
28
|
+
* - 'TestCycleStatus' - Archive a test cycle status
|
|
29
|
+
* - 'TestExecutionStatus' - Archive a test execution status
|
|
22
30
|
*
|
|
23
31
|
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
24
32
|
* The endpoint may change or be removed at any time without notice.
|
|
25
33
|
*
|
|
26
34
|
* @param credentials - Private API credentials
|
|
27
35
|
* @param request - Archive config request
|
|
28
|
-
* @param request.type - Type of config item: 'Environment' or '
|
|
29
|
-
* @param request.id - Numeric ID of the
|
|
36
|
+
* @param request.type - Type of config item: 'Environment', 'Iteration', 'TestCaseStatus', 'TestPlanStatus', 'TestCycleStatus', or 'TestExecutionStatus'
|
|
37
|
+
* @param request.id - Numeric ID of the config item to archive
|
|
30
38
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
31
39
|
* @returns Archive response with the ID of the archived item
|
|
32
40
|
* @throws {BadRequestError} If the request is invalid
|
|
33
41
|
* @throws {UnauthorizedError} If authentication fails
|
|
34
42
|
* @throws {ForbiddenError} If the user doesn't have permission
|
|
35
|
-
* @throws {NotFoundError} If the
|
|
43
|
+
* @throws {NotFoundError} If the config item is not found
|
|
36
44
|
* @throws {ServerError} If the server returns an error
|
|
37
45
|
*/
|
|
38
46
|
async archiveConfig(credentials, request) {
|
|
39
47
|
return this.updateArchiveStatus(credentials, request, true);
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
|
-
* Unarchive a config item
|
|
50
|
+
* Unarchive a config item using private API
|
|
51
|
+
*
|
|
52
|
+
* Unarchives a config item (Environment, Iteration, or Status) by setting its `isArchived` flag to `false`.
|
|
43
53
|
*
|
|
44
|
-
*
|
|
54
|
+
* Supported config types:
|
|
55
|
+
* - 'Environment' - Unarchive an environment
|
|
56
|
+
* - 'Iteration' - Unarchive an iteration
|
|
57
|
+
* - 'TestCaseStatus' - Unarchive a test case status
|
|
58
|
+
* - 'TestPlanStatus' - Unarchive a test plan status
|
|
59
|
+
* - 'TestCycleStatus' - Unarchive a test cycle status
|
|
60
|
+
* - 'TestExecutionStatus' - Unarchive a test execution status
|
|
45
61
|
*
|
|
46
62
|
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
47
63
|
* The endpoint may change or be removed at any time without notice.
|
|
48
64
|
*
|
|
49
65
|
* @param credentials - Private API credentials
|
|
50
66
|
* @param request - Archive config request (same interface as archive, but sets isArchived to false)
|
|
51
|
-
* @param request.type - Type of config item: 'Environment' or '
|
|
52
|
-
* @param request.id - Numeric ID of the
|
|
67
|
+
* @param request.type - Type of config item: 'Environment', 'Iteration', 'TestCaseStatus', 'TestPlanStatus', 'TestCycleStatus', or 'TestExecutionStatus'
|
|
68
|
+
* @param request.id - Numeric ID of the config item to unarchive
|
|
53
69
|
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
54
70
|
* @returns Archive response with the ID of the unarchived item
|
|
55
71
|
* @throws {BadRequestError} If the request is invalid
|
|
56
72
|
* @throws {UnauthorizedError} If authentication fails
|
|
57
73
|
* @throws {ForbiddenError} If the user doesn't have permission
|
|
58
|
-
* @throws {NotFoundError} If the
|
|
74
|
+
* @throws {NotFoundError} If the config item is not found
|
|
59
75
|
* @throws {ServerError} If the server returns an error
|
|
60
76
|
*/
|
|
61
77
|
async unarchiveConfig(credentials, request) {
|
|
@@ -67,8 +83,16 @@ export class PrivateConfig extends PrivateBase {
|
|
|
67
83
|
async updateArchiveStatus(credentials, request, isArchived) {
|
|
68
84
|
// Get Context JWT
|
|
69
85
|
const contextJwt = await this.getContextJwt(credentials);
|
|
70
|
-
//
|
|
71
|
-
const
|
|
86
|
+
// Map config type to endpoint path
|
|
87
|
+
const endpointMap = {
|
|
88
|
+
Environment: 'environment',
|
|
89
|
+
Iteration: 'iteration',
|
|
90
|
+
TestCaseStatus: 'testcasestatus',
|
|
91
|
+
TestPlanStatus: 'testplanstatus',
|
|
92
|
+
TestCycleStatus: 'testrunstatus',
|
|
93
|
+
TestExecutionStatus: 'testresultstatus',
|
|
94
|
+
};
|
|
95
|
+
const endpoint = endpointMap[request.type];
|
|
72
96
|
const url = `${this.privateApiBaseUrl}/${endpoint}/${request.id}`;
|
|
73
97
|
const headers = {
|
|
74
98
|
'Content-Type': 'application/json',
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright Adaptavist 2025 (c) All rights reserved
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Private API Iteration Data sub-group
|
|
6
|
+
* Supplements public API with iteration data for Test Cycles and Test Executions
|
|
7
|
+
*
|
|
8
|
+
* ⚠️ WARNING: These methods use private APIs that are not officially supported.
|
|
9
|
+
*/
|
|
10
|
+
import type { PrivateApiCredentials, GetTestCycleIterationRequest, TestCycleIterationResponse, UpdateTestCycleIterationRequest, GetTestExecutionIterationRequest, TestExecutionIterationResponse, UpdateTestExecutionIterationRequest } from '../../types';
|
|
11
|
+
import type { ZephyrApiConnection } from '../../index';
|
|
12
|
+
import { PrivateBase } from './PrivateBase';
|
|
13
|
+
export declare class PrivateIterationData extends PrivateBase {
|
|
14
|
+
constructor(apiConnection?: ZephyrApiConnection);
|
|
15
|
+
/**
|
|
16
|
+
* Get test cycle iteration using private API
|
|
17
|
+
*
|
|
18
|
+
* Retrieves iteration data for a test cycle that is not available in the public API.
|
|
19
|
+
* Use this to supplement the public `getTestCycle()` response with iteration information.
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
22
|
+
* The endpoint may change or be removed at any time without notice.
|
|
23
|
+
*
|
|
24
|
+
* @param credentials - Private API credentials
|
|
25
|
+
* @param request - Get test cycle iteration request
|
|
26
|
+
* @param request.testCycleKey - Test cycle key (e.g., "M12-R1")
|
|
27
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
28
|
+
* @returns Test cycle iteration response with iterationId (null if not set)
|
|
29
|
+
* @throws {BadRequestError} If the request is invalid
|
|
30
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
31
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
32
|
+
* @throws {NotFoundError} If the test cycle is not found
|
|
33
|
+
* @throws {ServerError} If the server returns an error
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Get iteration for a test cycle (supplements public getTestCycle)
|
|
38
|
+
* const publicData = await api.TestCycle.getTestCycle({ key: 'M12-R1' });
|
|
39
|
+
* const iterationData = await api.Private.IterationData.getTestCycleIteration(credentials, {
|
|
40
|
+
* testCycleKey: 'M12-R1',
|
|
41
|
+
* projectId: 10313
|
|
42
|
+
* });
|
|
43
|
+
* console.log('Iteration ID:', iterationData.iterationId);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
getTestCycleIteration(credentials: PrivateApiCredentials, request: GetTestCycleIterationRequest): Promise<TestCycleIterationResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Update test cycle iteration using private API
|
|
49
|
+
*
|
|
50
|
+
* Sets or clears the iteration for a test cycle. Use this to supplement
|
|
51
|
+
* a test cycle created via the public API with iteration data.
|
|
52
|
+
*
|
|
53
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
54
|
+
* The endpoint may change or be removed at any time without notice.
|
|
55
|
+
*
|
|
56
|
+
* @param credentials - Private API credentials
|
|
57
|
+
* @param request - Update test cycle iteration request
|
|
58
|
+
* @param request.testCycleKey - Test cycle key (e.g., "M12-R1")
|
|
59
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
60
|
+
* @param request.iterationId - Iteration ID to set, or null to clear
|
|
61
|
+
* @throws {BadRequestError} If the request is invalid
|
|
62
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
63
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
64
|
+
* @throws {NotFoundError} If the test cycle is not found
|
|
65
|
+
* @throws {ServerError} If the server returns an error
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // Create test cycle with public API, then set iteration with private API
|
|
70
|
+
* const testCycle = await api.TestCycle.createTestCycle({
|
|
71
|
+
* projectKey: 'M12',
|
|
72
|
+
* name: 'Sprint 1 Testing'
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Set iteration using private API
|
|
76
|
+
* await api.Private.IterationData.updateTestCycleIteration(credentials, {
|
|
77
|
+
* testCycleKey: testCycle.key,
|
|
78
|
+
* projectId: 10313,
|
|
79
|
+
* iterationId: 10952254
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
updateTestCycleIteration(credentials: PrivateApiCredentials, request: UpdateTestCycleIterationRequest): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Get test execution iteration using private API
|
|
86
|
+
*
|
|
87
|
+
* Retrieves iteration data for a test execution that is not available in the public API.
|
|
88
|
+
* Use this to supplement the public `getTestExecution()` response with iteration information.
|
|
89
|
+
*
|
|
90
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
91
|
+
* The endpoint may change or be removed at any time without notice.
|
|
92
|
+
*
|
|
93
|
+
* @param credentials - Private API credentials
|
|
94
|
+
* @param request - Get test execution iteration request
|
|
95
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M12-E1")
|
|
96
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
97
|
+
* @returns Test execution iteration response with iterationId (null if not set)
|
|
98
|
+
* @throws {BadRequestError} If the request is invalid
|
|
99
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
100
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
101
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
102
|
+
* @throws {ServerError} If the server returns an error
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // Get iteration for a test execution (supplements public getTestExecution)
|
|
107
|
+
* const publicData = await api.TestExecution.getTestExecution({ key: 'M12-E1' });
|
|
108
|
+
* const iterationData = await api.Private.IterationData.getTestExecutionIteration(credentials, {
|
|
109
|
+
* testExecutionKey: 'M12-E1',
|
|
110
|
+
* projectId: 10313
|
|
111
|
+
* });
|
|
112
|
+
* console.log('Iteration ID:', iterationData.iterationId);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
getTestExecutionIteration(credentials: PrivateApiCredentials, request: GetTestExecutionIterationRequest): Promise<TestExecutionIterationResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Update test execution iteration using private API
|
|
118
|
+
*
|
|
119
|
+
* Sets or clears the iteration for a test execution. Use this to supplement
|
|
120
|
+
* a test execution created via the public API with iteration data.
|
|
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 - Update test execution iteration request
|
|
127
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M12-E1")
|
|
128
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
129
|
+
* @param request.iterationId - Iteration ID to set, or null to clear
|
|
130
|
+
* @throws {BadRequestError} If the request is invalid
|
|
131
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
132
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
133
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
134
|
+
* @throws {ServerError} If the server returns an error
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* // Create test execution with public API (returns void), then set iteration with private API
|
|
139
|
+
* await api.TestExecution.createTestExecution({
|
|
140
|
+
* projectKey: 'M12',
|
|
141
|
+
* testCaseKey: 'M12-T1',
|
|
142
|
+
* testCycleKey: 'M12-R1',
|
|
143
|
+
* statusName: 'Pass'
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Note: createTestExecution returns no data, so use known key or look up after creation
|
|
147
|
+
* // Set iteration using private API
|
|
148
|
+
* await api.Private.IterationData.updateTestExecutionIteration(credentials, {
|
|
149
|
+
* testExecutionKey: 'M12-E1', // Use known key or look up via listTestExecutions()
|
|
150
|
+
* projectId: 10313,
|
|
151
|
+
* iterationId: 10952254
|
|
152
|
+
* });
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
updateTestExecutionIteration(credentials: PrivateApiCredentials, request: UpdateTestExecutionIterationRequest): Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=PrivateIterationData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrivateIterationData.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateIterationData.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,mCAAmC,EACnC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA8B5C,qBAAa,oBAAqB,SAAQ,WAAW;gBACxC,aAAa,CAAC,EAAE,mBAAmB;IAQ/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,qBAAqB,CAC1B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAqEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,wBAAwB,CAC7B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,+BAA+B,GACtC,OAAO,CAAC,IAAI,CAAC;IAgFhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,yBAAyB,CAC9B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,gCAAgC,GACvC,OAAO,CAAC,8BAA8B,CAAC;IAqE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACG,4BAA4B,CACjC,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,mCAAmC,GAC1C,OAAO,CAAC,IAAI,CAAC;CA0EhB"}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright Adaptavist 2025 (c) All rights reserved
|
|
3
|
+
*/
|
|
4
|
+
import { PrivateBase } from './PrivateBase';
|
|
5
|
+
import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ServerError, UnexpectedError, } from '../../utils';
|
|
6
|
+
export class PrivateIterationData extends PrivateBase {
|
|
7
|
+
constructor(apiConnection) {
|
|
8
|
+
super(apiConnection);
|
|
9
|
+
}
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Test Cycle Iteration Methods
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Get test cycle iteration using private API
|
|
15
|
+
*
|
|
16
|
+
* Retrieves iteration data for a test cycle that is not available in the public API.
|
|
17
|
+
* Use this to supplement the public `getTestCycle()` response with iteration information.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
20
|
+
* The endpoint may change or be removed at any time without notice.
|
|
21
|
+
*
|
|
22
|
+
* @param credentials - Private API credentials
|
|
23
|
+
* @param request - Get test cycle iteration request
|
|
24
|
+
* @param request.testCycleKey - Test cycle key (e.g., "M12-R1")
|
|
25
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
26
|
+
* @returns Test cycle iteration response with iterationId (null if not set)
|
|
27
|
+
* @throws {BadRequestError} If the request is invalid
|
|
28
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
29
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
30
|
+
* @throws {NotFoundError} If the test cycle is not found
|
|
31
|
+
* @throws {ServerError} If the server returns an error
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Get iteration for a test cycle (supplements public getTestCycle)
|
|
36
|
+
* const publicData = await api.TestCycle.getTestCycle({ key: 'M12-R1' });
|
|
37
|
+
* const iterationData = await api.Private.IterationData.getTestCycleIteration(credentials, {
|
|
38
|
+
* testCycleKey: 'M12-R1',
|
|
39
|
+
* projectId: 10313
|
|
40
|
+
* });
|
|
41
|
+
* console.log('Iteration ID:', iterationData.iterationId);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
async getTestCycleIteration(credentials, request) {
|
|
45
|
+
// Get Context JWT
|
|
46
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
47
|
+
// Build URL with minimal fields needed
|
|
48
|
+
const fields = 'id,key,iterationId';
|
|
49
|
+
const url = `${this.privateApiBaseUrl}/testrun/${request.testCycleKey}?fields=${encodeURIComponent(fields)}`;
|
|
50
|
+
const headers = {
|
|
51
|
+
accept: 'application/json',
|
|
52
|
+
authorization: `JWT ${contextJwt}`,
|
|
53
|
+
'jira-project-id': String(request.projectId),
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
const response = await fetch(url, {
|
|
57
|
+
method: 'GET',
|
|
58
|
+
headers,
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
if (response.status === 400) {
|
|
62
|
+
throw new BadRequestError(`Invalid request parameters for getting test cycle iteration.`);
|
|
63
|
+
}
|
|
64
|
+
if (response.status === 401) {
|
|
65
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
66
|
+
}
|
|
67
|
+
if (response.status === 403) {
|
|
68
|
+
throw new ForbiddenError('Insufficient permissions to get test cycle iteration.');
|
|
69
|
+
}
|
|
70
|
+
if (response.status === 404) {
|
|
71
|
+
throw new NotFoundError(`Test cycle '${request.testCycleKey}' not found.`);
|
|
72
|
+
}
|
|
73
|
+
throw new ServerError(`Failed to get test cycle iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
74
|
+
}
|
|
75
|
+
const data = (await response.json());
|
|
76
|
+
return {
|
|
77
|
+
id: data.id,
|
|
78
|
+
key: data.key,
|
|
79
|
+
iterationId: data.iterationId ?? null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof BadRequestError ||
|
|
84
|
+
error instanceof UnauthorizedError ||
|
|
85
|
+
error instanceof ForbiddenError ||
|
|
86
|
+
error instanceof NotFoundError ||
|
|
87
|
+
error instanceof ServerError ||
|
|
88
|
+
error instanceof UnexpectedError) {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
throw new UnexpectedError(`Unexpected error while getting test cycle iteration for '${request.testCycleKey}'`, error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Update test cycle iteration using private API
|
|
96
|
+
*
|
|
97
|
+
* Sets or clears the iteration for a test cycle. Use this to supplement
|
|
98
|
+
* a test cycle created via the public API with iteration data.
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
101
|
+
* The endpoint may change or be removed at any time without notice.
|
|
102
|
+
*
|
|
103
|
+
* @param credentials - Private API credentials
|
|
104
|
+
* @param request - Update test cycle iteration request
|
|
105
|
+
* @param request.testCycleKey - Test cycle key (e.g., "M12-R1")
|
|
106
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
107
|
+
* @param request.iterationId - Iteration ID to set, or null to clear
|
|
108
|
+
* @throws {BadRequestError} If the request is invalid
|
|
109
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
110
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
111
|
+
* @throws {NotFoundError} If the test cycle is not found
|
|
112
|
+
* @throws {ServerError} If the server returns an error
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Create test cycle with public API, then set iteration with private API
|
|
117
|
+
* const testCycle = await api.TestCycle.createTestCycle({
|
|
118
|
+
* projectKey: 'M12',
|
|
119
|
+
* name: 'Sprint 1 Testing'
|
|
120
|
+
* });
|
|
121
|
+
*
|
|
122
|
+
* // Set iteration using private API
|
|
123
|
+
* await api.Private.IterationData.updateTestCycleIteration(credentials, {
|
|
124
|
+
* testCycleKey: testCycle.key,
|
|
125
|
+
* projectId: 10313,
|
|
126
|
+
* iterationId: 10952254
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
async updateTestCycleIteration(credentials, request) {
|
|
131
|
+
// Get Context JWT
|
|
132
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
133
|
+
// First, get the numeric ID for the test cycle
|
|
134
|
+
const testCycleData = await this.getTestCycleIteration(credentials, {
|
|
135
|
+
testCycleKey: request.testCycleKey,
|
|
136
|
+
projectId: request.projectId,
|
|
137
|
+
});
|
|
138
|
+
// Build URL with numeric ID
|
|
139
|
+
const url = `${this.privateApiBaseUrl}/testrun/${testCycleData.id}`;
|
|
140
|
+
const headers = {
|
|
141
|
+
'Content-Type': 'application/json',
|
|
142
|
+
accept: 'application/json',
|
|
143
|
+
authorization: `JWT ${contextJwt}`,
|
|
144
|
+
'jira-project-id': String(request.projectId),
|
|
145
|
+
};
|
|
146
|
+
const requestBody = {
|
|
147
|
+
id: testCycleData.id,
|
|
148
|
+
projectId: request.projectId,
|
|
149
|
+
iterationId: request.iterationId,
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
const response = await fetch(url, {
|
|
153
|
+
method: 'PUT',
|
|
154
|
+
headers,
|
|
155
|
+
body: JSON.stringify(requestBody),
|
|
156
|
+
});
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
if (response.status === 400) {
|
|
159
|
+
throw new BadRequestError(`Invalid request parameters for updating test cycle iteration.`);
|
|
160
|
+
}
|
|
161
|
+
if (response.status === 401) {
|
|
162
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
163
|
+
}
|
|
164
|
+
if (response.status === 403) {
|
|
165
|
+
throw new ForbiddenError('Insufficient permissions to update test cycle iteration.');
|
|
166
|
+
}
|
|
167
|
+
if (response.status === 404) {
|
|
168
|
+
throw new NotFoundError(`Test cycle '${request.testCycleKey}' not found.`);
|
|
169
|
+
}
|
|
170
|
+
throw new ServerError(`Failed to update test cycle iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
171
|
+
}
|
|
172
|
+
// Response is empty on success
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (error instanceof BadRequestError ||
|
|
176
|
+
error instanceof UnauthorizedError ||
|
|
177
|
+
error instanceof ForbiddenError ||
|
|
178
|
+
error instanceof NotFoundError ||
|
|
179
|
+
error instanceof ServerError ||
|
|
180
|
+
error instanceof UnexpectedError) {
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
throw new UnexpectedError(`Unexpected error while updating test cycle iteration for '${request.testCycleKey}'`, error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// Test Execution Iteration Methods
|
|
188
|
+
// ============================================================================
|
|
189
|
+
/**
|
|
190
|
+
* Get test execution iteration using private API
|
|
191
|
+
*
|
|
192
|
+
* Retrieves iteration data for a test execution that is not available in the public API.
|
|
193
|
+
* Use this to supplement the public `getTestExecution()` response with iteration information.
|
|
194
|
+
*
|
|
195
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
196
|
+
* The endpoint may change or be removed at any time without notice.
|
|
197
|
+
*
|
|
198
|
+
* @param credentials - Private API credentials
|
|
199
|
+
* @param request - Get test execution iteration request
|
|
200
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M12-E1")
|
|
201
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
202
|
+
* @returns Test execution iteration response with iterationId (null if not set)
|
|
203
|
+
* @throws {BadRequestError} If the request is invalid
|
|
204
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
205
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
206
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
207
|
+
* @throws {ServerError} If the server returns an error
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // Get iteration for a test execution (supplements public getTestExecution)
|
|
212
|
+
* const publicData = await api.TestExecution.getTestExecution({ key: 'M12-E1' });
|
|
213
|
+
* const iterationData = await api.Private.IterationData.getTestExecutionIteration(credentials, {
|
|
214
|
+
* testExecutionKey: 'M12-E1',
|
|
215
|
+
* projectId: 10313
|
|
216
|
+
* });
|
|
217
|
+
* console.log('Iteration ID:', iterationData.iterationId);
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
async getTestExecutionIteration(credentials, request) {
|
|
221
|
+
// Get Context JWT
|
|
222
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
223
|
+
// Build URL with minimal fields needed
|
|
224
|
+
const fields = 'id,key,iterationId';
|
|
225
|
+
const url = `${this.privateApiBaseUrl}/testresult/${request.testExecutionKey}?fields=${encodeURIComponent(fields)}&itemId=${request.testExecutionKey}`;
|
|
226
|
+
const headers = {
|
|
227
|
+
accept: 'application/json',
|
|
228
|
+
authorization: `JWT ${contextJwt}`,
|
|
229
|
+
'jira-project-id': String(request.projectId),
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
const response = await fetch(url, {
|
|
233
|
+
method: 'GET',
|
|
234
|
+
headers,
|
|
235
|
+
});
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
if (response.status === 400) {
|
|
238
|
+
throw new BadRequestError(`Invalid request parameters for getting test execution iteration.`);
|
|
239
|
+
}
|
|
240
|
+
if (response.status === 401) {
|
|
241
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
242
|
+
}
|
|
243
|
+
if (response.status === 403) {
|
|
244
|
+
throw new ForbiddenError('Insufficient permissions to get test execution iteration.');
|
|
245
|
+
}
|
|
246
|
+
if (response.status === 404) {
|
|
247
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' not found.`);
|
|
248
|
+
}
|
|
249
|
+
throw new ServerError(`Failed to get test execution iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
250
|
+
}
|
|
251
|
+
const data = (await response.json());
|
|
252
|
+
return {
|
|
253
|
+
id: data.id,
|
|
254
|
+
key: data.key,
|
|
255
|
+
iterationId: data.iterationId ?? null,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (error instanceof BadRequestError ||
|
|
260
|
+
error instanceof UnauthorizedError ||
|
|
261
|
+
error instanceof ForbiddenError ||
|
|
262
|
+
error instanceof NotFoundError ||
|
|
263
|
+
error instanceof ServerError ||
|
|
264
|
+
error instanceof UnexpectedError) {
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
throw new UnexpectedError(`Unexpected error while getting test execution iteration for '${request.testExecutionKey}'`, error);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Update test execution iteration using private API
|
|
272
|
+
*
|
|
273
|
+
* Sets or clears the iteration for a test execution. Use this to supplement
|
|
274
|
+
* a test execution created via the public API with iteration data.
|
|
275
|
+
*
|
|
276
|
+
* ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
|
|
277
|
+
* The endpoint may change or be removed at any time without notice.
|
|
278
|
+
*
|
|
279
|
+
* @param credentials - Private API credentials
|
|
280
|
+
* @param request - Update test execution iteration request
|
|
281
|
+
* @param request.testExecutionKey - Test execution key (e.g., "M12-E1")
|
|
282
|
+
* @param request.projectId - Jira project ID (numeric, not the project key)
|
|
283
|
+
* @param request.iterationId - Iteration ID to set, or null to clear
|
|
284
|
+
* @throws {BadRequestError} If the request is invalid
|
|
285
|
+
* @throws {UnauthorizedError} If authentication fails
|
|
286
|
+
* @throws {ForbiddenError} If the user doesn't have permission
|
|
287
|
+
* @throws {NotFoundError} If the test execution is not found
|
|
288
|
+
* @throws {ServerError} If the server returns an error
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* // Create test execution with public API (returns void), then set iteration with private API
|
|
293
|
+
* await api.TestExecution.createTestExecution({
|
|
294
|
+
* projectKey: 'M12',
|
|
295
|
+
* testCaseKey: 'M12-T1',
|
|
296
|
+
* testCycleKey: 'M12-R1',
|
|
297
|
+
* statusName: 'Pass'
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Note: createTestExecution returns no data, so use known key or look up after creation
|
|
301
|
+
* // Set iteration using private API
|
|
302
|
+
* await api.Private.IterationData.updateTestExecutionIteration(credentials, {
|
|
303
|
+
* testExecutionKey: 'M12-E1', // Use known key or look up via listTestExecutions()
|
|
304
|
+
* projectId: 10313,
|
|
305
|
+
* iterationId: 10952254
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
async updateTestExecutionIteration(credentials, request) {
|
|
310
|
+
// Get Context JWT
|
|
311
|
+
const contextJwt = await this.getContextJwt(credentials);
|
|
312
|
+
// First, get the numeric ID for the test execution
|
|
313
|
+
const testExecutionData = await this.getTestExecutionIteration(credentials, {
|
|
314
|
+
testExecutionKey: request.testExecutionKey,
|
|
315
|
+
projectId: request.projectId,
|
|
316
|
+
});
|
|
317
|
+
// Build URL with numeric ID
|
|
318
|
+
const url = `${this.privateApiBaseUrl}/testresult/${testExecutionData.id}`;
|
|
319
|
+
const headers = {
|
|
320
|
+
'Content-Type': 'application/json',
|
|
321
|
+
accept: 'application/json',
|
|
322
|
+
authorization: `JWT ${contextJwt}`,
|
|
323
|
+
'jira-project-id': String(request.projectId),
|
|
324
|
+
};
|
|
325
|
+
const requestBody = {
|
|
326
|
+
id: testExecutionData.id,
|
|
327
|
+
iterationId: request.iterationId,
|
|
328
|
+
};
|
|
329
|
+
try {
|
|
330
|
+
const response = await fetch(url, {
|
|
331
|
+
method: 'PUT',
|
|
332
|
+
headers,
|
|
333
|
+
body: JSON.stringify(requestBody),
|
|
334
|
+
});
|
|
335
|
+
if (!response.ok) {
|
|
336
|
+
if (response.status === 400) {
|
|
337
|
+
throw new BadRequestError(`Invalid request parameters for updating test execution iteration.`);
|
|
338
|
+
}
|
|
339
|
+
if (response.status === 401) {
|
|
340
|
+
throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
|
|
341
|
+
}
|
|
342
|
+
if (response.status === 403) {
|
|
343
|
+
throw new ForbiddenError('Insufficient permissions to update test execution iteration.');
|
|
344
|
+
}
|
|
345
|
+
if (response.status === 404) {
|
|
346
|
+
throw new NotFoundError(`Test execution '${request.testExecutionKey}' not found.`);
|
|
347
|
+
}
|
|
348
|
+
throw new ServerError(`Failed to update test execution iteration. Status: ${response.status}`, response.status, response.statusText);
|
|
349
|
+
}
|
|
350
|
+
// Response is empty on success
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
if (error instanceof BadRequestError ||
|
|
354
|
+
error instanceof UnauthorizedError ||
|
|
355
|
+
error instanceof ForbiddenError ||
|
|
356
|
+
error instanceof NotFoundError ||
|
|
357
|
+
error instanceof ServerError ||
|
|
358
|
+
error instanceof UnexpectedError) {
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
throw new UnexpectedError(`Unexpected error while updating test execution iteration for '${request.testExecutionKey}'`, error);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
package/dist/groups/Private.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { PrivateVersions } from './Private/PrivateVersions';
|
|
|
9
9
|
import { PrivateAttachments } from './Private/PrivateAttachments';
|
|
10
10
|
import { PrivateAuthentication } from './Private/PrivateAuthentication';
|
|
11
11
|
import { PrivateVersionControl } from './Private/PrivateVersionControl';
|
|
12
|
+
import { PrivateIterationData } from './Private/PrivateIterationData';
|
|
12
13
|
/**
|
|
13
14
|
* Private API group for accessing Zephyr's private/unofficial endpoints
|
|
14
15
|
*
|
|
@@ -40,6 +41,11 @@ export declare class PrivateGroup extends PrivateBase {
|
|
|
40
41
|
* Version Control sub-group - Get version-specific data (links, test script, test steps)
|
|
41
42
|
*/
|
|
42
43
|
readonly VersionControl: PrivateVersionControl;
|
|
44
|
+
/**
|
|
45
|
+
* Iteration Data sub-group - Get and set iteration data for Test Cycles and Test Executions
|
|
46
|
+
* Supplements public API with iteration data not available in public endpoints
|
|
47
|
+
*/
|
|
48
|
+
readonly IterationData: PrivateIterationData;
|
|
43
49
|
constructor(apiConnection?: ZephyrApiConnection);
|
|
44
50
|
}
|
|
45
51
|
//# sourceMappingURL=Private.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Private.d.ts","sourceRoot":"","sources":["../../groups/Private.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyDH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"Private.d.ts","sourceRoot":"","sources":["../../groups/Private.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyDH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAStE;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC5C;;OAEG;IACH,SAAgB,cAAc,EAAE,qBAAqB,CAAC;IAEtD;;OAEG;IACH,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAE1C;;OAEG;IACH,SAAgB,MAAM,EAAE,aAAa,CAAC;IAEtC;;OAEG;IACH,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,kBAAkB,CAAC;IAEhD;;OAEG;IACH,SAAgB,cAAc,EAAE,qBAAqB,CAAC;IAEtD;;;OAGG;IACH,SAAgB,aAAa,EAAE,oBAAoB,CAAC;gBAExC,aAAa,CAAC,EAAE,mBAAmB;CAW/C"}
|
package/dist/groups/Private.js
CHANGED
|
@@ -8,6 +8,7 @@ import { PrivateVersions } from './Private/PrivateVersions';
|
|
|
8
8
|
import { PrivateAttachments } from './Private/PrivateAttachments';
|
|
9
9
|
import { PrivateAuthentication } from './Private/PrivateAuthentication';
|
|
10
10
|
import { PrivateVersionControl } from './Private/PrivateVersionControl';
|
|
11
|
+
import { PrivateIterationData } from './Private/PrivateIterationData';
|
|
11
12
|
/**
|
|
12
13
|
* Private API group for accessing Zephyr's private/unofficial endpoints
|
|
13
14
|
*
|
|
@@ -23,5 +24,6 @@ export class PrivateGroup extends PrivateBase {
|
|
|
23
24
|
this.Versions = new PrivateVersions(apiConnection);
|
|
24
25
|
this.Attachments = new PrivateAttachments(apiConnection);
|
|
25
26
|
this.VersionControl = new PrivateVersionControl(apiConnection);
|
|
27
|
+
this.IterationData = new PrivateIterationData(apiConnection);
|
|
26
28
|
}
|
|
27
29
|
}
|