@rbaileysr/zephyr-managed-api 1.3.2 → 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.
@@ -6,6 +6,7 @@ import { PrivateCustomFields } from './PrivateCustomFields';
6
6
  import { PrivateLabels } from './PrivateLabels';
7
7
  import { PrivateIterations } from './PrivateIterations';
8
8
  import { PrivateDataSets } from './PrivateDataSets';
9
+ import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ServerError, UnexpectedError, } from '../../utils';
9
10
  export class PrivateConfig extends PrivateBase {
10
11
  constructor(apiConnection) {
11
12
  super(apiConnection);
@@ -14,4 +15,103 @@ export class PrivateConfig extends PrivateBase {
14
15
  this.Iterations = new PrivateIterations(apiConnection);
15
16
  this.DataSets = new PrivateDataSets(apiConnection);
16
17
  }
18
+ /**
19
+ * Archive a config item (Environment or Iteration) using private API
20
+ *
21
+ * Archives an Environment or Iteration by setting its `isArchived` flag to `true`.
22
+ *
23
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
24
+ * The endpoint may change or be removed at any time without notice.
25
+ *
26
+ * @param credentials - Private API credentials
27
+ * @param request - Archive config request
28
+ * @param request.type - Type of config item: 'Environment' or 'Iteration'
29
+ * @param request.id - Numeric ID of the environment or iteration to archive
30
+ * @param request.projectId - Jira project ID (numeric, not the project key)
31
+ * @returns Archive response with the ID of the archived item
32
+ * @throws {BadRequestError} If the request is invalid
33
+ * @throws {UnauthorizedError} If authentication fails
34
+ * @throws {ForbiddenError} If the user doesn't have permission
35
+ * @throws {NotFoundError} If the environment or iteration is not found
36
+ * @throws {ServerError} If the server returns an error
37
+ */
38
+ async archiveConfig(credentials, request) {
39
+ return this.updateArchiveStatus(credentials, request, true);
40
+ }
41
+ /**
42
+ * Unarchive a config item (Environment or Iteration) using private API
43
+ *
44
+ * Unarchives an Environment or Iteration by setting its `isArchived` flag to `false`.
45
+ *
46
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
47
+ * The endpoint may change or be removed at any time without notice.
48
+ *
49
+ * @param credentials - Private API credentials
50
+ * @param request - Archive config request (same interface as archive, but sets isArchived to false)
51
+ * @param request.type - Type of config item: 'Environment' or 'Iteration'
52
+ * @param request.id - Numeric ID of the environment or iteration to unarchive
53
+ * @param request.projectId - Jira project ID (numeric, not the project key)
54
+ * @returns Archive response with the ID of the unarchived item
55
+ * @throws {BadRequestError} If the request is invalid
56
+ * @throws {UnauthorizedError} If authentication fails
57
+ * @throws {ForbiddenError} If the user doesn't have permission
58
+ * @throws {NotFoundError} If the environment or iteration is not found
59
+ * @throws {ServerError} If the server returns an error
60
+ */
61
+ async unarchiveConfig(credentials, request) {
62
+ return this.updateArchiveStatus(credentials, request, false);
63
+ }
64
+ /**
65
+ * Internal method to update archive status
66
+ */
67
+ async updateArchiveStatus(credentials, request, isArchived) {
68
+ // Get Context JWT
69
+ const contextJwt = await this.getContextJwt(credentials);
70
+ // Determine endpoint based on type
71
+ const endpoint = request.type.toLowerCase(); // 'environment' or 'iteration'
72
+ const url = `${this.privateApiBaseUrl}/${endpoint}/${request.id}`;
73
+ const headers = {
74
+ 'Content-Type': 'application/json',
75
+ authorization: `JWT ${contextJwt}`,
76
+ 'jira-project-id': String(request.projectId),
77
+ };
78
+ const requestBody = {
79
+ id: request.id,
80
+ isArchived,
81
+ };
82
+ try {
83
+ const response = await fetch(url, {
84
+ method: 'PUT',
85
+ headers,
86
+ body: JSON.stringify(requestBody),
87
+ });
88
+ if (!response.ok) {
89
+ if (response.status === 400) {
90
+ throw new BadRequestError(`Invalid request parameters for ${isArchived ? 'archiving' : 'unarchiving'} ${request.type.toLowerCase()}.`);
91
+ }
92
+ if (response.status === 401) {
93
+ throw new UnauthorizedError('Failed to authenticate. Please check your credentials.');
94
+ }
95
+ if (response.status === 403) {
96
+ throw new ForbiddenError(`Insufficient permissions to ${isArchived ? 'archive' : 'unarchive'} ${request.type.toLowerCase()}.`);
97
+ }
98
+ if (response.status === 404) {
99
+ throw new NotFoundError(`${request.type} with ID '${request.id}' not found.`);
100
+ }
101
+ throw new ServerError(`Failed to ${isArchived ? 'archive' : 'unarchive'} ${request.type.toLowerCase()}. Status: ${response.status}`, response.status, response.statusText);
102
+ }
103
+ return (await response.json());
104
+ }
105
+ catch (error) {
106
+ if (error instanceof BadRequestError ||
107
+ error instanceof UnauthorizedError ||
108
+ error instanceof ForbiddenError ||
109
+ error instanceof NotFoundError ||
110
+ error instanceof ServerError ||
111
+ error instanceof UnexpectedError) {
112
+ throw error;
113
+ }
114
+ throw new UnexpectedError(`Unexpected error while ${isArchived ? 'archiving' : 'unarchiving'} ${request.type.toLowerCase()}`, error);
115
+ }
116
+ }
17
117
  }
@@ -0,0 +1,169 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ /**
5
+ * Private API Version Control sub-group
6
+ * Handles version-specific operations for test case links, test script, and test steps
7
+ *
8
+ * ⚠️ WARNING: These methods use private APIs that are not officially supported.
9
+ */
10
+ import type { PrivateApiCredentials, GetTestCaseIssueLinksRequest, GetTestCaseWebLinksRequest, GetTestCaseTestScriptRequest, GetTestCaseTestStepsRequest, GetTestExecutionStepIssueLinksRequest, CreateTestExecutionStepIssueLinkRequest, CreateTestExecutionStepIssueLinkResponse, TestExecutionStepIssueLinkList, IssueLinkList, WebLinkList, TestScript, TestStepsList } from '../../types';
11
+ import { PrivateBase } from './PrivateBase';
12
+ import type { ZephyrApiConnection } from '../../index';
13
+ export declare class PrivateVersionControl extends PrivateBase {
14
+ constructor(apiConnection?: ZephyrApiConnection);
15
+ /**
16
+ * Get issue links for a test case using private API (with version support)
17
+ *
18
+ * Retrieves all issue links associated with a test case, optionally for a specific version.
19
+ * The response format matches the public API `getTestCaseLinks().issues` format.
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 issue links request
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
+ * @param request.projectId - Jira project ID (numeric, not the project key)
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
+ * @returns Array of issue links matching the public API format
30
+ * @throws {BadRequestError} If the request is invalid
31
+ * @throws {UnauthorizedError} If authentication fails
32
+ * @throws {ForbiddenError} If the user doesn't have permission
33
+ * @throws {NotFoundError} If the test case is not found
34
+ * @throws {ServerError} If the server returns an error
35
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
36
+ */
37
+ getTestCaseIssueLinks(credentials: PrivateApiCredentials, request: GetTestCaseIssueLinksRequest): Promise<IssueLinkList>;
38
+ /**
39
+ * Get web links for a test case using private API (with version support)
40
+ *
41
+ * Retrieves all web links associated with a test case, optionally for a specific version.
42
+ * The response format matches the public API `getTestCaseLinks().webLinks` format.
43
+ *
44
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
45
+ * The endpoint may change or be removed at any time without notice.
46
+ *
47
+ * @param credentials - Private API credentials
48
+ * @param request - Get web links request
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
+ * @param request.projectId - Jira project ID (numeric, not the project key)
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
+ * @returns Array of web links matching the public API format
53
+ * @throws {BadRequestError} If the request is invalid
54
+ * @throws {UnauthorizedError} If authentication fails
55
+ * @throws {ForbiddenError} If the user doesn't have permission
56
+ * @throws {NotFoundError} If the test case is not found
57
+ * @throws {ServerError} If the server returns an error
58
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
59
+ */
60
+ getTestCaseWebLinks(credentials: PrivateApiCredentials, request: GetTestCaseWebLinksRequest): Promise<WebLinkList>;
61
+ /**
62
+ * Get test script for a test case using private API (with version support)
63
+ *
64
+ * Retrieves the test script associated with a test case, optionally for a specific version.
65
+ * The response format matches the public API `getTestCaseTestScript()` format.
66
+ *
67
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
68
+ * The endpoint may change or be removed at any time without notice.
69
+ *
70
+ * @param credentials - Private API credentials
71
+ * @param request - Get test script request
72
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1')
73
+ * @param request.projectId - Jira project ID (numeric, not the project key)
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
+ * @returns Test script matching the public API format, or null if no test script exists
76
+ * @throws {BadRequestError} If the request is invalid
77
+ * @throws {UnauthorizedError} If authentication fails
78
+ * @throws {ForbiddenError} If the user doesn't have permission
79
+ * @throws {NotFoundError} If the test case is not found
80
+ * @throws {ServerError} If the server returns an error
81
+ * @throws {UnexpectedError} If test case cannot be retrieved
82
+ */
83
+ getTestCaseTestScript(credentials: PrivateApiCredentials, request: GetTestCaseTestScriptRequest): Promise<TestScript | null>;
84
+ /**
85
+ * Get test steps for a test case using private API (with version support)
86
+ *
87
+ * Retrieves the test steps associated with a test case, optionally for a specific version.
88
+ * The response format matches the public API `getTestCaseTestSteps()` format.
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 steps request
95
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1')
96
+ * @param request.projectId - Jira project ID (numeric, not the project key)
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
+ * @returns Test steps list matching the public API format
99
+ * @throws {BadRequestError} If the request is invalid
100
+ * @throws {UnauthorizedError} If authentication fails
101
+ * @throws {ForbiddenError} If the user doesn't have permission
102
+ * @throws {NotFoundError} If the test case is not found
103
+ * @throws {ServerError} If the server returns an error
104
+ * @throws {UnexpectedError} If test case cannot be retrieved
105
+ */
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>;
168
+ }
169
+ //# sourceMappingURL=PrivateVersionControl.d.ts.map
@@ -0,0 +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,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;I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