@rbaileysr/zephyr-managed-api 1.2.1 → 1.2.8

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.
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ /**
5
+ * Private API Authentication sub-group
6
+ * Handles Jira Context JWT token retrieval
7
+ *
8
+ * ⚠️ WARNING: These methods use private APIs that are not officially supported.
9
+ */
10
+ import type { PrivateApiCredentials } from '../../types';
11
+ import { PrivateBase } from './PrivateBase';
12
+ import type { ZephyrApiConnection } from '../../index';
13
+ export declare class PrivateAuthentication extends PrivateBase {
14
+ constructor(apiConnection?: ZephyrApiConnection);
15
+ /**
16
+ * Get Jira Context JWT token
17
+ *
18
+ * Retrieves a short-lived JWT token (15 minutes) from Jira that is required
19
+ * for private Zephyr API endpoints. This token may need to be refreshed
20
+ * during long operations.
21
+ *
22
+ * ⚠️ WARNING: This uses a private Jira endpoint and may change without notice.
23
+ *
24
+ * @param credentials - Private API credentials
25
+ * @returns The Context JWT token string
26
+ */
27
+ getContextJwt(credentials: PrivateApiCredentials): Promise<string>;
28
+ }
29
+ //# sourceMappingURL=PrivateAuthentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrivateAuthentication.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateAuthentication.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,qBAAa,qBAAsB,SAAQ,WAAW;gBACzC,aAAa,CAAC,EAAE,mBAAmB;IAI/C;;;;;;;;;;;OAWG;IACG,aAAa,CAAC,WAAW,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;CAGxE"}
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ import { PrivateBase } from './PrivateBase';
5
+ export class PrivateAuthentication extends PrivateBase {
6
+ constructor(apiConnection) {
7
+ super(apiConnection);
8
+ }
9
+ /**
10
+ * Get Jira Context JWT token
11
+ *
12
+ * Retrieves a short-lived JWT token (15 minutes) from Jira that is required
13
+ * for private Zephyr API endpoints. This token may need to be refreshed
14
+ * during long operations.
15
+ *
16
+ * ⚠️ WARNING: This uses a private Jira endpoint and may change without notice.
17
+ *
18
+ * @param credentials - Private API credentials
19
+ * @returns The Context JWT token string
20
+ */
21
+ async getContextJwt(credentials) {
22
+ return super.getContextJwt(credentials);
23
+ }
24
+ }
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ /**
5
+ * Base class for Private API sub-groups
6
+ * Provides shared resources and utilities
7
+ */
8
+ import type { PrivateApiCredentials } from '../../types';
9
+ import type { ZephyrApiConnection } from '../../index';
10
+ import { TestCaseGroup } from '../TestCase';
11
+ import { TestCycleGroup } from '../TestCycle';
12
+ import { TestPlanGroup } from '../TestPlan';
13
+ import { TestExecutionGroup } from '../TestExecution';
14
+ export declare class PrivateBase {
15
+ protected readonly privateApiBaseUrl = "https://app.tm4j.smartbear.com/backend/rest/tests/2.0";
16
+ protected readonly testCaseGroup?: TestCaseGroup;
17
+ protected readonly testCycleGroup?: TestCycleGroup;
18
+ protected readonly testPlanGroup?: TestPlanGroup;
19
+ protected readonly testExecutionGroup?: TestExecutionGroup;
20
+ constructor(apiConnection?: ZephyrApiConnection);
21
+ /**
22
+ * Get Jira Context JWT token
23
+ *
24
+ * Retrieves a short-lived JWT token (15 minutes) from Jira that is required
25
+ * for private Zephyr API endpoints. This token may need to be refreshed
26
+ * during long operations.
27
+ *
28
+ * ⚠️ WARNING: This uses a private Jira endpoint and may change without notice.
29
+ */
30
+ protected getContextJwt(credentials: PrivateApiCredentials): Promise<string>;
31
+ }
32
+ //# sourceMappingURL=PrivateBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrivateBase.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateBase.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,qBAAa,WAAW;IACvB,SAAS,CAAC,QAAQ,CAAC,iBAAiB,2DAA2D;IAC/F,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;gBAE/C,aAAa,CAAC,EAAE,mBAAmB;IAS/C;;;;;;;;OAQG;cACa,aAAa,CAAC,WAAW,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;CAsElF"}
@@ -0,0 +1,77 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ import { TestCaseGroup } from '../TestCase';
5
+ import { TestCycleGroup } from '../TestCycle';
6
+ import { TestPlanGroup } from '../TestPlan';
7
+ import { TestExecutionGroup } from '../TestExecution';
8
+ import { UnauthorizedError, ServerError, UnexpectedError } from '../../utils';
9
+ export class PrivateBase {
10
+ constructor(apiConnection) {
11
+ this.privateApiBaseUrl = 'https://app.tm4j.smartbear.com/backend/rest/tests/2.0';
12
+ if (apiConnection) {
13
+ this.testCaseGroup = new TestCaseGroup(apiConnection);
14
+ this.testCycleGroup = new TestCycleGroup(apiConnection);
15
+ this.testPlanGroup = new TestPlanGroup(apiConnection);
16
+ this.testExecutionGroup = new TestExecutionGroup(apiConnection);
17
+ }
18
+ }
19
+ /**
20
+ * Get Jira Context JWT token
21
+ *
22
+ * Retrieves a short-lived JWT token (15 minutes) from Jira that is required
23
+ * for private Zephyr API endpoints. This token may need to be refreshed
24
+ * during long operations.
25
+ *
26
+ * ⚠️ WARNING: This uses a private Jira endpoint and may change without notice.
27
+ */
28
+ async getContextJwt(credentials) {
29
+ const url = `${credentials.jiraInstanceUrl}/plugins/servlet/ac/com.kanoah.test-manager/main-project-page`;
30
+ // Create Basic Auth header
31
+ const authCredentials = btoa(`${credentials.userEmail}:${credentials.apiToken}`);
32
+ const headers = {
33
+ 'Authorization': `Basic ${authCredentials}`,
34
+ 'Content-Type': 'application/json',
35
+ };
36
+ try {
37
+ const response = await fetch(url, {
38
+ method: 'POST',
39
+ headers,
40
+ });
41
+ if (!response.ok) {
42
+ if (response.status === 401) {
43
+ throw new UnauthorizedError('Failed to authenticate with Jira. Please check your email and API token.');
44
+ }
45
+ throw new ServerError(`Failed to retrieve Context JWT. Status: ${response.status}`, response.status, response.statusText);
46
+ }
47
+ const responseText = await response.text();
48
+ // Extract contextJwt using regex (as per documentation)
49
+ const match = responseText.match(/"contextJwt":"([^"]+)"/);
50
+ if (!match || !match[1]) {
51
+ // Retry once if JWT is missing (as per documentation)
52
+ const retryResponse = await fetch(url, {
53
+ method: 'POST',
54
+ headers,
55
+ });
56
+ if (!retryResponse.ok) {
57
+ throw new ServerError(`Failed to retrieve Context JWT on retry. Status: ${retryResponse.status}`, retryResponse.status, retryResponse.statusText);
58
+ }
59
+ const retryText = await retryResponse.text();
60
+ const retryMatch = retryText.match(/"contextJwt":"([^"]+)"/);
61
+ if (!retryMatch || !retryMatch[1]) {
62
+ throw new UnexpectedError('Context JWT not found in response after retry. This may be a Jira bug or API change.', { responseText: retryText });
63
+ }
64
+ return retryMatch[1];
65
+ }
66
+ return match[1];
67
+ }
68
+ catch (error) {
69
+ if (error instanceof UnauthorizedError ||
70
+ error instanceof ServerError ||
71
+ error instanceof UnexpectedError) {
72
+ throw error;
73
+ }
74
+ throw new UnexpectedError('Unexpected error while retrieving Context JWT', error);
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,149 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ /**
5
+ * Private API Comments sub-group
6
+ * Handles comment-related operations for test cases, test cycles, and test plans
7
+ *
8
+ * ⚠️ WARNING: These methods use private APIs that are not officially supported.
9
+ */
10
+ import type { PrivateApiCredentials, PrivateComment, GetTestCaseCommentsRequest, GetTestCycleCommentsRequest, GetTestPlanCommentsRequest, CreateTestCaseCommentRequest, CreateTestCaseCommentResponse, CreateTestCycleCommentRequest, CreateTestPlanCommentRequest, CreateCommentResponse } from '../../types';
11
+ import { PrivateBase } from './PrivateBase';
12
+ import type { ZephyrApiConnection } from '../../index';
13
+ export declare class PrivateComments extends PrivateBase {
14
+ constructor(apiConnection?: ZephyrApiConnection);
15
+ /**
16
+ * Get comments for a test case using private API
17
+ *
18
+ * Retrieves all comments associated with a test case.
19
+ *
20
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
21
+ * The endpoint may change or be removed at any time without notice.
22
+ *
23
+ * @param credentials - Private API credentials
24
+ * @param request - Get comments request
25
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
26
+ * @param request.projectId - Jira project ID (numeric, not the project key)
27
+ * @returns Array of comments
28
+ * @throws {BadRequestError} If the request is invalid
29
+ * @throws {UnauthorizedError} If authentication fails
30
+ * @throws {ForbiddenError} If the user doesn't have permission
31
+ * @throws {NotFoundError} If the test case is not found
32
+ * @throws {ServerError} If the server returns an error
33
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
34
+ */
35
+ getTestCaseComments(credentials: PrivateApiCredentials, request: GetTestCaseCommentsRequest): Promise<PrivateComment[]>;
36
+ /**
37
+ * Get comments for a test cycle using private API
38
+ *
39
+ * Retrieves all comments associated with a test cycle (test run).
40
+ *
41
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
42
+ * The endpoint may change or be removed at any time without notice.
43
+ *
44
+ * @param credentials - Private API credentials
45
+ * @param request - Get comments request
46
+ * @param request.testCycleId - Test cycle ID (numeric)
47
+ * @param request.projectId - Jira project ID (numeric, not the project key)
48
+ * @returns Array of comments
49
+ * @throws {BadRequestError} If the request is invalid
50
+ * @throws {UnauthorizedError} If authentication fails
51
+ * @throws {ForbiddenError} If the user doesn't have permission
52
+ * @throws {NotFoundError} If the test cycle is not found
53
+ * @throws {ServerError} If the server returns an error
54
+ */
55
+ getTestCycleComments(credentials: PrivateApiCredentials, request: GetTestCycleCommentsRequest): Promise<PrivateComment[]>;
56
+ /**
57
+ * Get comments for a test plan using private API
58
+ *
59
+ * Retrieves all comments associated with a test plan.
60
+ *
61
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
62
+ * The endpoint may change or be removed at any time without notice.
63
+ *
64
+ * @param credentials - Private API credentials
65
+ * @param request - Get comments request
66
+ * @param request.testPlanId - Test plan ID (numeric)
67
+ * @param request.projectId - Jira project ID (numeric, not the project key)
68
+ * @returns Array of comments
69
+ * @throws {BadRequestError} If the request is invalid
70
+ * @throws {UnauthorizedError} If authentication fails
71
+ * @throws {ForbiddenError} If the user doesn't have permission
72
+ * @throws {NotFoundError} If the test plan is not found
73
+ * @throws {ServerError} If the server returns an error
74
+ */
75
+ getTestPlanComments(credentials: PrivateApiCredentials, request: GetTestPlanCommentsRequest): Promise<PrivateComment[]>;
76
+ /**
77
+ * Create a comment on a test case using private API
78
+ *
79
+ * Adds a comment to an existing test case. The comment will be associated with
80
+ * the specified user account ID.
81
+ *
82
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
83
+ * The endpoint may change or be removed at any time without notice.
84
+ *
85
+ * @param credentials - Private API credentials
86
+ * @param request - Comment creation request
87
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
88
+ * @param request.projectId - Jira project ID (numeric, not the project key)
89
+ * @param request.body - Comment text/body
90
+ * @param request.createdBy - Atlassian account ID of the user creating the comment (e.g., '5d6fdc98dc6e480dbc021aae')
91
+ * @returns Comment creation response
92
+ * @throws {BadRequestError} If the request is invalid
93
+ * @throws {UnauthorizedError} If authentication fails
94
+ * @throws {ForbiddenError} If the user doesn't have permission
95
+ * @throws {NotFoundError} If the test case is not found
96
+ * @throws {ServerError} If the server returns an error
97
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
98
+ */
99
+ createTestCaseComment(credentials: PrivateApiCredentials, request: CreateTestCaseCommentRequest): Promise<CreateTestCaseCommentResponse>;
100
+ /**
101
+ * Create a comment on a test cycle using private API
102
+ *
103
+ * Adds a comment to an existing test cycle (test run). The comment will be associated with
104
+ * the specified user account ID.
105
+ *
106
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
107
+ * The endpoint may change or be removed at any time without notice.
108
+ *
109
+ * @param credentials - Private API credentials
110
+ * @param request - Comment creation request
111
+ * @param request.testCycleKey - Test cycle key (e.g., 'PROJ-R1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
112
+ * @param request.projectId - Jira project ID (numeric, not the project key)
113
+ * @param request.body - Comment text/body
114
+ * @param request.createdBy - Atlassian account ID of the user creating the comment (e.g., '5d6fdc98dc6e480dbc021aae')
115
+ * @returns Comment creation response
116
+ * @throws {BadRequestError} If the request is invalid
117
+ * @throws {UnauthorizedError} If authentication fails
118
+ * @throws {ForbiddenError} If the user doesn't have permission
119
+ * @throws {NotFoundError} If the test cycle is not found
120
+ * @throws {ServerError} If the server returns an error
121
+ * @throws {UnexpectedError} If test cycle ID cannot be looked up from key and Zephyr Connector is not available
122
+ */
123
+ createTestCycleComment(credentials: PrivateApiCredentials, request: CreateTestCycleCommentRequest): Promise<CreateCommentResponse>;
124
+ /**
125
+ * Create a comment on a test plan using private API
126
+ *
127
+ * Adds a comment to an existing test plan. The comment will be associated with
128
+ * the specified user account ID.
129
+ *
130
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
131
+ * The endpoint may change or be removed at any time without notice.
132
+ *
133
+ * @param credentials - Private API credentials
134
+ * @param request - Comment creation request
135
+ * @param request.testPlanKey - Test plan key (e.g., 'PROJ-P1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
136
+ * @param request.projectId - Jira project ID (numeric, not the project key)
137
+ * @param request.body - Comment text/body
138
+ * @param request.createdBy - Atlassian account ID of the user creating the comment (e.g., '5d6fdc98dc6e480dbc021aae')
139
+ * @returns Comment creation response
140
+ * @throws {BadRequestError} If the request is invalid
141
+ * @throws {UnauthorizedError} If authentication fails
142
+ * @throws {ForbiddenError} If the user doesn't have permission
143
+ * @throws {NotFoundError} If the test plan is not found
144
+ * @throws {ServerError} If the server returns an error
145
+ * @throws {UnexpectedError} If test plan ID cannot be looked up from key and Zephyr Connector is not available
146
+ */
147
+ createTestPlanComment(credentials: PrivateApiCredentials, request: CreateTestPlanCommentRequest): Promise<CreateCommentResponse>;
148
+ }
149
+ //# sourceMappingURL=PrivateComments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrivateComments.d.ts","sourceRoot":"","sources":["../../../groups/Private/PrivateComments.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,qBAAa,eAAgB,SAAQ,WAAW;gBACnC,aAAa,CAAC,EAAE,mBAAmB;IAI/C;;;;;;;;;;;;;;;;;;;OAmBG;IACG,mBAAmB,CACxB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,0BAA0B,GACjC,OAAO,CAAC,cAAc,EAAE,CAAC;IA6E5B;;;;;;;;;;;;;;;;;;OAkBG;IACG,oBAAoB,CACzB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,cAAc,EAAE,CAAC;IAqD5B;;;;;;;;;;;;;;;;;;OAkBG;IACG,mBAAmB,CACxB,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,0BAA0B,GACjC,OAAO,CAAC,cAAc,EAAE,CAAC;IAqD5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,qBAAqB,CAC1B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,6BAA6B,CAAC;IAoFzC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,sBAAsB,CAC3B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,6BAA6B,GACpC,OAAO,CAAC,qBAAqB,CAAC;IAoFjC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,qBAAqB,CAC1B,WAAW,EAAE,qBAAqB,EAClC,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,qBAAqB,CAAC;CAmFjC"}