@rbaileysr/zephyr-managed-api 1.3.3 → 1.3.5

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.
@@ -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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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,EAKb,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;CAgIzB"}
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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 (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.). If not provided, uses the latest version (same as version: 1).
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, where 1 is the current version)
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}
@@ -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, where 1 is the current version)
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",
3
+ "version": "1.3.5",
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
@@ -428,7 +428,8 @@ export interface TestStepTestCaseParameters {
428
428
  /**
429
429
  * Test step test case
430
430
  */
431
- export interface TestStepTestCase extends Link {
431
+ export interface TestStepTestCase {
432
+ self?: string;
432
433
  testCaseKey: string;
433
434
  parameters?: TestStepTestCaseParameters[];
434
435
  }
@@ -1529,9 +1530,8 @@ export interface GetTestCaseCommentsRequest {
1529
1530
  testCaseKey: string;
1530
1531
  projectId: number;
1531
1532
  /**
1532
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
1533
- * If not provided or undefined, uses the latest version (same as version: 1).
1534
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
1533
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
1534
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
1535
1535
  */
1536
1536
  version?: number;
1537
1537
  }
@@ -1578,9 +1578,8 @@ export interface GetTestCaseAttachmentsRequest {
1578
1578
  testCaseKey: string;
1579
1579
  projectId: number;
1580
1580
  /**
1581
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
1582
- * If not provided or undefined, uses the latest version (same as version: 1).
1583
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
1581
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
1582
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
1584
1583
  */
1585
1584
  version?: number;
1586
1585
  }
@@ -1592,9 +1591,8 @@ export interface DownloadAttachmentRequest {
1592
1591
  projectId: number;
1593
1592
  attachmentId: string;
1594
1593
  /**
1595
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
1596
- * If not provided or undefined, uses the latest version (same as version: 1).
1597
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
1594
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
1595
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
1598
1596
  */
1599
1597
  version?: number;
1600
1598
  }
@@ -1966,6 +1964,33 @@ export interface UpdateDataSetResponse {
1966
1964
  export interface GetDataSetsRequest {
1967
1965
  projectId: number;
1968
1966
  }
1967
+ /**
1968
+ * Config type for archive/unarchive operations
1969
+ */
1970
+ export type ConfigType = 'Environment' | 'Iteration';
1971
+ /**
1972
+ * Archive config request for private API
1973
+ */
1974
+ export interface ArchiveConfigRequest {
1975
+ /**
1976
+ * Type of config item: 'Environment' or 'Iteration'
1977
+ */
1978
+ type: ConfigType;
1979
+ /**
1980
+ * Numeric ID of the environment or iteration to archive
1981
+ */
1982
+ id: number;
1983
+ /**
1984
+ * Jira project ID (numeric, not the project key)
1985
+ */
1986
+ projectId: number;
1987
+ }
1988
+ /**
1989
+ * Archive config response for private API
1990
+ */
1991
+ export interface ArchiveConfigResponse {
1992
+ id: number;
1993
+ }
1969
1994
  /**
1970
1995
  * Get test case issue links request for private API
1971
1996
  */
@@ -1973,9 +1998,8 @@ export interface GetTestCaseIssueLinksRequest {
1973
1998
  testCaseKey: string;
1974
1999
  projectId: number;
1975
2000
  /**
1976
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
1977
- * If not provided or undefined, uses the latest version (same as version: 1).
1978
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
2001
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
2002
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
1979
2003
  */
1980
2004
  version?: number;
1981
2005
  }
@@ -1986,9 +2010,8 @@ export interface GetTestCaseWebLinksRequest {
1986
2010
  testCaseKey: string;
1987
2011
  projectId: number;
1988
2012
  /**
1989
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
1990
- * If not provided or undefined, uses the latest version (same as version: 1).
1991
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
2013
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
2014
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
1992
2015
  */
1993
2016
  version?: number;
1994
2017
  }
@@ -1999,9 +2022,8 @@ export interface GetTestCaseTestScriptRequest {
1999
2022
  testCaseKey: string;
2000
2023
  projectId: number;
2001
2024
  /**
2002
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
2003
- * If not provided or undefined, uses the latest version (same as version: 1).
2004
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
2025
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
2026
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
2005
2027
  */
2006
2028
  version?: number;
2007
2029
  }
@@ -2012,10 +2034,48 @@ export interface GetTestCaseTestStepsRequest {
2012
2034
  testCaseKey: string;
2013
2035
  projectId: number;
2014
2036
  /**
2015
- * Optional version number (relative to current version, where 1 = current/latest version, 2 = previous version, 3 = version before that, etc.).
2016
- * If not provided or undefined, uses the latest version (same as version: 1).
2017
- * Note: Version numbers are relative, not absolute. To get the first version ever created, you need to know the total number of versions.
2037
+ * Optional version number (absolute, 1-based: 1 = first version ever created, 2 = second version, etc. The highest number is the current/latest version).
2038
+ * If not provided or undefined, uses the latest version. Use `listTestCaseVersions()` to find the total number of versions and identify the latest.
2018
2039
  */
2019
2040
  version?: number;
2020
2041
  }
2042
+ /**
2043
+ * Create test execution step issue link request for private API
2044
+ */
2045
+ export interface CreateTestExecutionStepIssueLinkRequest {
2046
+ testExecutionKey: string;
2047
+ stepIndex: number;
2048
+ /**
2049
+ * Jira issue ID (can be provided as number or string, will be converted to string for API)
2050
+ */
2051
+ issueId: number | string;
2052
+ type: LinkType;
2053
+ projectId: number;
2054
+ }
2055
+ /**
2056
+ * Create test execution step issue link response for private API
2057
+ */
2058
+ export interface CreateTestExecutionStepIssueLinkResponse {
2059
+ id: number;
2060
+ }
2061
+ /**
2062
+ * Get test execution step issue links request for private API
2063
+ */
2064
+ export interface GetTestExecutionStepIssueLinksRequest {
2065
+ testExecutionKey: string;
2066
+ stepIndex: number;
2067
+ projectId: number;
2068
+ }
2069
+ /**
2070
+ * Test execution step issue link (from private API response)
2071
+ */
2072
+ export interface TestExecutionStepIssueLink {
2073
+ id: number;
2074
+ issueId: string;
2075
+ type: LinkType;
2076
+ }
2077
+ /**
2078
+ * Test execution step issue link list
2079
+ */
2080
+ export type TestExecutionStepIssueLinkList = TestExecutionStepIssueLink[];
2021
2081
  //# sourceMappingURL=types.d.ts.map