@rbaileysr/zephyr-managed-api 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,256 @@
1
+ /*!
2
+ * Copyright Adaptavist 2025 (c) All rights reserved
3
+ */
4
+ /**
5
+ * Private API group
6
+ *
7
+ * ⚠️ WARNING: These functions use Zephyr's private/unofficial API endpoints.
8
+ *
9
+ * These endpoints are:
10
+ * - Not officially supported by SmartBear
11
+ * - Not part of the public API documentation
12
+ * - Subject to change at any time without notice
13
+ * - Not covered by Standard Support
14
+ *
15
+ * Use these functions at your own risk. They may break with future Zephyr updates.
16
+ */
17
+ import type { CreatePrivateCustomFieldRequest, PrivateCustomFieldCategory, CreateTestCaseVersionRequest, CreateTestCaseVersionResponse, CreateAttachmentRequest, CreateTestCaseCommentRequest, CreateTestCaseCommentResponse, GetTestCaseAttachmentsRequest, GetTestCaseAttachmentsResponse, DownloadAttachmentRequest } from '../types';
18
+ import type { ZephyrApiConnection } from '../index';
19
+ /**
20
+ * Private API group for accessing Zephyr's private/unofficial endpoints
21
+ *
22
+ * ⚠️ WARNING: These methods use private APIs that are not officially supported.
23
+ * They may change or break at any time without notice.
24
+ */
25
+ export declare class PrivateGroup {
26
+ /**
27
+ * Base URL for Zephyr private API endpoints
28
+ */
29
+ private readonly privateApiBaseUrl;
30
+ /**
31
+ * Optional API connection for accessing public API (e.g., to look up test case IDs from keys)
32
+ */
33
+ private readonly apiConnection?;
34
+ private readonly testCaseGroup?;
35
+ constructor(apiConnection?: ZephyrApiConnection);
36
+ /**
37
+ * Get Jira Context JWT token
38
+ *
39
+ * Retrieves a short-lived JWT token (15 minutes) from Jira that is required
40
+ * for private Zephyr API endpoints. This token may need to be refreshed
41
+ * during long operations.
42
+ *
43
+ * ⚠️ WARNING: This uses a private Jira endpoint and may change without notice.
44
+ *
45
+ * @param userEmail - Jira user email address
46
+ * @param apiToken - Jira API token
47
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
48
+ * @returns The Context JWT token string
49
+ * @throws {UnauthorizedError} If authentication fails
50
+ * @throws {UnexpectedError} If the JWT cannot be extracted from the response
51
+ */
52
+ getContextJwt(userEmail: string, apiToken: string, jiraInstanceUrl: string): Promise<string>;
53
+ /**
54
+ * Create a custom field using private API
55
+ *
56
+ * Creates a custom field for the specified entity type (test case, test plan, test run, or test step).
57
+ *
58
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
59
+ * The endpoint may change or be removed at any time without notice.
60
+ *
61
+ * @param userEmail - Jira user email address
62
+ * @param apiToken - Jira API token
63
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
64
+ * @param category - Entity type for the custom field (TEST_CASE, TEST_PLAN, TEST_RUN, or TEST_STEP)
65
+ * @param request - Custom field creation request
66
+ * @returns The created custom field response
67
+ * @throws {BadRequestError} If the request is invalid
68
+ * @throws {UnauthorizedError} If authentication fails
69
+ * @throws {ForbiddenError} If the user doesn't have permission
70
+ * @throws {ServerError} If the server returns an error
71
+ */
72
+ createCustomField(userEmail: string, apiToken: string, jiraInstanceUrl: string, category: PrivateCustomFieldCategory, request: CreatePrivateCustomFieldRequest): Promise<unknown>;
73
+ /**
74
+ * Create a new test case version using private API
75
+ *
76
+ * Creates a new version of an existing test case. Note that when a new version
77
+ * is created, the testCaseId changes for that test case.
78
+ *
79
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
80
+ * The endpoint may change or be removed at any time without notice.
81
+ *
82
+ * @param userEmail - Jira user email address
83
+ * @param apiToken - Jira API token
84
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
85
+ * @param request - Test case version creation request
86
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
87
+ * @param request.projectId - Jira project ID (numeric, not the project key)
88
+ * @returns The created version response with id and key
89
+ * @throws {BadRequestError} If the request is invalid
90
+ * @throws {UnauthorizedError} If authentication fails
91
+ * @throws {ForbiddenError} If the user doesn't have permission
92
+ * @throws {NotFoundError} If the test case is not found
93
+ * @throws {ServerError} If the server returns an error (including 409 Conflict if version already exists)
94
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
95
+ */
96
+ createTestCaseVersion(userEmail: string, apiToken: string, jiraInstanceUrl: string, request: CreateTestCaseVersionRequest): Promise<CreateTestCaseVersionResponse>;
97
+ /**
98
+ * Get upload details for attachment upload
99
+ *
100
+ * Retrieves S3 upload credentials and configuration needed to upload an attachment.
101
+ *
102
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
103
+ * The endpoint may change or be removed at any time without notice.
104
+ *
105
+ * @param contextJwt - Jira Context JWT token
106
+ * @returns Upload details including S3 bucket URL, credentials, and policy
107
+ * @throws {UnauthorizedError} If authentication fails
108
+ * @throws {ServerError} If the server returns an error
109
+ */
110
+ private getUploadDetails;
111
+ /**
112
+ * Upload file to S3
113
+ *
114
+ * Uploads a file to S3 using the credentials from upload details.
115
+ *
116
+ * @param upload - Upload details from getUploadDetails
117
+ * @param projectId - Jira project ID
118
+ * @param testCaseId - Numeric test case ID
119
+ * @param userAccountId - Atlassian account ID
120
+ * @param file - File to upload (Blob or ArrayBuffer)
121
+ * @param fileName - Name of the file
122
+ * @returns S3 upload information
123
+ * @throws {UnexpectedError} If upload fails
124
+ */
125
+ private uploadToS3;
126
+ /**
127
+ * Save attachment metadata
128
+ *
129
+ * Saves metadata for an uploaded attachment.
130
+ *
131
+ * @param contextJwt - Jira Context JWT token
132
+ * @param projectId - Jira project ID
133
+ * @param testCaseId - Numeric test case ID
134
+ * @param userAccountId - Atlassian account ID
135
+ * @param s3Key - S3 key from upload
136
+ * @param fileName - File name
137
+ * @param mimeType - MIME type
138
+ * @param fileSize - File size in bytes
139
+ * @returns Attachment metadata response
140
+ * @throws {BadRequestError} If the request is invalid
141
+ * @throws {UnauthorizedError} If authentication fails
142
+ * @throws {ServerError} If the server returns an error
143
+ */
144
+ private saveAttachmentMetadata;
145
+ /**
146
+ * Create a comment on a test case using private API
147
+ *
148
+ * Adds a comment to an existing test case. The comment will be associated with
149
+ * the specified user account ID.
150
+ *
151
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
152
+ * The endpoint may change or be removed at any time without notice.
153
+ *
154
+ * @param userEmail - Jira user email address
155
+ * @param apiToken - Jira API token
156
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
157
+ * @param request - Comment creation request
158
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
159
+ * @param request.projectId - Jira project ID (numeric, not the project key)
160
+ * @param request.body - Comment text/body
161
+ * @param request.createdBy - Atlassian account ID of the user creating the comment (e.g., '5d6fdc98dc6e480dbc021aae')
162
+ * @returns Comment creation response
163
+ * @throws {BadRequestError} If the request is invalid
164
+ * @throws {UnauthorizedError} If authentication fails
165
+ * @throws {ForbiddenError} If the user doesn't have permission
166
+ * @throws {NotFoundError} If the test case is not found
167
+ * @throws {ServerError} If the server returns an error
168
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
169
+ */
170
+ createTestCaseComment(userEmail: string, apiToken: string, jiraInstanceUrl: string, request: CreateTestCaseCommentRequest): Promise<CreateTestCaseCommentResponse>;
171
+ /**
172
+ * Get attachments for a test case using private API
173
+ *
174
+ * Retrieves all attachment details for a test case, including signed S3 URLs
175
+ * for downloading the attachments.
176
+ *
177
+ * ⚠️ WARNING: This uses a private Zephyr API endpoint that is not officially supported.
178
+ * The endpoint may change or be removed at any time without notice.
179
+ *
180
+ * @param userEmail - Jira user email address
181
+ * @param apiToken - Jira API token
182
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
183
+ * @param request - Get attachments request
184
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
185
+ * @param request.projectId - Jira project ID (numeric, not the project key)
186
+ * @returns Test case attachments response with array of attachment details
187
+ * @throws {BadRequestError} If the request is invalid
188
+ * @throws {UnauthorizedError} If authentication fails
189
+ * @throws {ForbiddenError} If the user doesn't have permission
190
+ * @throws {NotFoundError} If the test case is not found
191
+ * @throws {ServerError} If the server returns an error
192
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
193
+ */
194
+ getTestCaseAttachments(userEmail: string, apiToken: string, jiraInstanceUrl: string, request: GetTestCaseAttachmentsRequest): Promise<GetTestCaseAttachmentsResponse>;
195
+ /**
196
+ * Download an attachment from a test case using private API
197
+ *
198
+ * Downloads an attachment file into memory. This method:
199
+ * 1. Gets fresh attachment details (including a fresh signed S3 URL)
200
+ * 2. Downloads the file from the signed URL
201
+ * 3. Returns the file as a Blob
202
+ *
203
+ * ⚠️ WARNING: This uses private Zephyr API endpoints that are not officially supported.
204
+ * The endpoints may change or be removed at any time without notice.
205
+ *
206
+ * @param userEmail - Jira user email address
207
+ * @param apiToken - Jira API token
208
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
209
+ * @param request - Download attachment request
210
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
211
+ * @param request.projectId - Jira project ID (numeric, not the project key)
212
+ * @param request.attachmentId - Attachment ID (UUID string, e.g., 'c3f14125-638f-47f9-9211-12a9777c09e7')
213
+ * @returns Blob containing the attachment file data
214
+ * @throws {BadRequestError} If the request is invalid
215
+ * @throws {UnauthorizedError} If authentication fails
216
+ * @throws {ForbiddenError} If the user doesn't have permission
217
+ * @throws {NotFoundError} If the test case or attachment is not found
218
+ * @throws {ServerError} If the server returns an error
219
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available, or if download fails
220
+ */
221
+ downloadAttachment(userEmail: string, apiToken: string, jiraInstanceUrl: string, request: DownloadAttachmentRequest): Promise<Blob>;
222
+ /**
223
+ * Get MIME type from file name
224
+ */
225
+ private getMimeType;
226
+ /**
227
+ * Create an attachment for a test case using private API
228
+ *
229
+ * Uploads a file attachment to a test case. This involves:
230
+ * 1. Getting upload details (S3 credentials)
231
+ * 2. Uploading the file to S3
232
+ * 3. Saving attachment metadata
233
+ *
234
+ * ⚠️ WARNING: This uses private Zephyr API endpoints that are not officially supported.
235
+ * The endpoints may change or be removed at any time without notice.
236
+ *
237
+ * @param userEmail - Jira user email address
238
+ * @param apiToken - Jira API token
239
+ * @param jiraInstanceUrl - Full Jira instance URL (e.g., 'https://your-instance.atlassian.net')
240
+ * @param request - Attachment creation request
241
+ * @param request.testCaseKey - Test case key (e.g., 'PROJ-T1'). The numeric ID will be looked up automatically if Zephyr Connector is available.
242
+ * @param request.projectId - Jira project ID (numeric, not the project key)
243
+ * @param request.file - File to upload (Blob or ArrayBuffer)
244
+ * @param request.fileName - Name of the file
245
+ * @param request.userAccountId - Atlassian account ID (e.g., '5d6fdc98dc6e480dbc021aae')
246
+ * @returns Attachment metadata response
247
+ * @throws {BadRequestError} If the request is invalid
248
+ * @throws {UnauthorizedError} If authentication fails
249
+ * @throws {ForbiddenError} If the user doesn't have permission
250
+ * @throws {NotFoundError} If the test case is not found
251
+ * @throws {ServerError} If the server returns an error
252
+ * @throws {UnexpectedError} If test case ID cannot be looked up from key and Zephyr Connector is not available
253
+ */
254
+ createAttachment(userEmail: string, apiToken: string, jiraInstanceUrl: string, request: CreateAttachmentRequest): Promise<unknown>;
255
+ }
256
+ //# sourceMappingURL=Private.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Private.d.ts","sourceRoot":"","sources":["../../groups/Private.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACX,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B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