@rbaileysr/zephyr-managed-api 1.0.1 → 1.1.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.
- package/README.md +189 -1
- package/dist/README.md +865 -0
- package/dist/error-strategy.d.ts +3 -0
- package/dist/error-strategy.d.ts.map +1 -1
- package/dist/error-strategy.js +3 -0
- package/dist/groups/All.d.ts +3 -0
- package/dist/groups/All.d.ts.map +1 -1
- package/dist/groups/All.js +2 -6
- package/dist/groups/Automation.d.ts +3 -0
- package/dist/groups/Automation.d.ts.map +1 -1
- package/dist/groups/Automation.js +2 -3
- package/dist/groups/Environment.d.ts +3 -0
- package/dist/groups/Environment.d.ts.map +1 -1
- package/dist/groups/Environment.js +2 -3
- package/dist/groups/Folder.d.ts +3 -0
- package/dist/groups/Folder.d.ts.map +1 -1
- package/dist/groups/Folder.js +2 -3
- package/dist/groups/IssueLink.d.ts +3 -0
- package/dist/groups/IssueLink.d.ts.map +1 -1
- package/dist/groups/IssueLink.js +2 -3
- package/dist/groups/Link.d.ts +3 -0
- package/dist/groups/Link.d.ts.map +1 -1
- package/dist/groups/Link.js +2 -3
- package/dist/groups/Priority.d.ts +3 -0
- package/dist/groups/Priority.d.ts.map +1 -1
- package/dist/groups/Priority.js +2 -3
- package/dist/groups/Private.d.ts +89 -0
- package/dist/groups/Private.d.ts.map +1 -0
- package/dist/groups/Private.js +221 -0
- package/dist/groups/Project.d.ts +3 -0
- package/dist/groups/Project.d.ts.map +1 -1
- package/dist/groups/Project.js +2 -3
- package/dist/groups/Status.d.ts +3 -0
- package/dist/groups/Status.d.ts.map +1 -1
- package/dist/groups/Status.js +2 -3
- package/dist/groups/TestCase.d.ts +3 -0
- package/dist/groups/TestCase.d.ts.map +1 -1
- package/dist/groups/TestCase.js +2 -3
- package/dist/groups/TestCycle.d.ts +3 -0
- package/dist/groups/TestCycle.d.ts.map +1 -1
- package/dist/groups/TestCycle.js +2 -3
- package/dist/groups/TestExecution.d.ts +3 -0
- package/dist/groups/TestExecution.d.ts.map +1 -1
- package/dist/groups/TestExecution.js +2 -3
- package/dist/groups/TestPlan.d.ts +3 -0
- package/dist/groups/TestPlan.d.ts.map +1 -1
- package/dist/groups/TestPlan.js +2 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/package.json +54 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/utils-api-call.d.ts +3 -0
- package/dist/utils-api-call.d.ts.map +1 -1
- package/dist/utils-api-call.js +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -331,6 +331,21 @@ The Managed API is organized into the following groups:
|
|
|
331
331
|
- `createJUnitExecutions(request)` - Upload JUnit XML results
|
|
332
332
|
- `retrieveBDDTestCases(options)` - Retrieve BDD feature files
|
|
333
333
|
|
|
334
|
+
### Private API ⚠️
|
|
335
|
+
> **⚠️ WARNING: Private API Methods**
|
|
336
|
+
>
|
|
337
|
+
> The following methods use Zephyr's private/unofficial API endpoints that are:
|
|
338
|
+
> - **Not officially supported** by SmartBear
|
|
339
|
+
> - **Not part of the public API documentation**
|
|
340
|
+
> - **Subject to change at any time** without notice
|
|
341
|
+
> - **Not covered by Standard Support**
|
|
342
|
+
>
|
|
343
|
+
> Use these methods at your own risk. They may break with future Zephyr updates.
|
|
344
|
+
|
|
345
|
+
- `getContextJwt(userEmail, apiToken, jiraInstanceUrl)` - Get Jira Context JWT token (required for private API calls)
|
|
346
|
+
- `createCustomField(userEmail, apiToken, jiraInstanceUrl, category, request)` - Create custom fields for test cases, test plans, test runs, or test steps
|
|
347
|
+
- `createTestCaseVersion(userEmail, apiToken, jiraInstanceUrl, testCaseId, projectId)` - Create a new test case version
|
|
348
|
+
|
|
334
349
|
## Authentication
|
|
335
350
|
|
|
336
351
|
### Using ScriptRunner Connect API Connection (Recommended)
|
|
@@ -370,6 +385,148 @@ const apiEU = Zephyr.createZephyrApi(
|
|
|
370
385
|
);
|
|
371
386
|
```
|
|
372
387
|
|
|
388
|
+
## Private API ⚠️
|
|
389
|
+
|
|
390
|
+
> **⚠️ WARNING: Private API Usage**
|
|
391
|
+
>
|
|
392
|
+
> The Private API methods use Zephyr's private/unofficial endpoints that are not officially supported by SmartBear. These endpoints may change or be removed at any time without notice and are not covered by Standard Support. Use these methods at your own risk.
|
|
393
|
+
|
|
394
|
+
The Private API group provides access to functionality not available in the public Zephyr API, such as creating custom fields and test case versions. These methods require Jira user credentials (email and API token) rather than OAuth tokens.
|
|
395
|
+
|
|
396
|
+
### Authentication
|
|
397
|
+
|
|
398
|
+
Private API methods use Jira Basic Authentication (email + API token) to retrieve a Context JWT token, which is then used to authenticate with Zephyr's private endpoints.
|
|
399
|
+
|
|
400
|
+
### Get Context JWT
|
|
401
|
+
|
|
402
|
+
The Context JWT is a short-lived token (15 minutes) required for all private API calls:
|
|
403
|
+
|
|
404
|
+
```typescript
|
|
405
|
+
import Zephyr from '@rbaileysr/zephyr-managed-api';
|
|
406
|
+
import ZephyrApiConnection from '../api/zephyr';
|
|
407
|
+
|
|
408
|
+
const api = Zephyr.createZephyrApi(ZephyrApiConnection);
|
|
409
|
+
|
|
410
|
+
// Get Context JWT token
|
|
411
|
+
const contextJwt = await api.Private.getContextJwt(
|
|
412
|
+
'user@example.com',
|
|
413
|
+
'jira-api-token',
|
|
414
|
+
'https://your-instance.atlassian.net'
|
|
415
|
+
);
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Create Custom Fields
|
|
419
|
+
|
|
420
|
+
Create custom fields for test cases, test plans, test runs, or test steps:
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
// Create a basic custom field for test cases
|
|
424
|
+
const customField = await api.Private.createCustomField(
|
|
425
|
+
'user@example.com',
|
|
426
|
+
'jira-api-token',
|
|
427
|
+
'https://your-instance.atlassian.net',
|
|
428
|
+
'TEST_CASE', // Category: TEST_CASE, TEST_PLAN, TEST_RUN, or TEST_STEP
|
|
429
|
+
{
|
|
430
|
+
projectId: 10017,
|
|
431
|
+
name: 'Build Number',
|
|
432
|
+
type: 'SINGLE_LINE_TEXT', // CHECKBOX, NUMBER, DECIMAL, SINGLE_LINE_TEXT, MULTI_LINE_TEXT, SINGLE_CHOICE_SELECT_LIST, MULTI_CHOICE_SELECT_LIST, USER_LIST, DATE
|
|
433
|
+
required: false,
|
|
434
|
+
index: 4,
|
|
435
|
+
category: 'TEST_CASE',
|
|
436
|
+
options: [], // Only for SINGLE_CHOICE_SELECT_LIST or MULTI_CHOICE_SELECT_LIST
|
|
437
|
+
archived: false
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
// Create a custom field with options (select list)
|
|
442
|
+
const selectField = await api.Private.createCustomField(
|
|
443
|
+
'user@example.com',
|
|
444
|
+
'jira-api-token',
|
|
445
|
+
'https://your-instance.atlassian.net',
|
|
446
|
+
'TEST_CASE',
|
|
447
|
+
{
|
|
448
|
+
projectId: 10017,
|
|
449
|
+
name: 'Test Category',
|
|
450
|
+
type: 'MULTI_CHOICE_SELECT_LIST',
|
|
451
|
+
required: false,
|
|
452
|
+
index: 5,
|
|
453
|
+
category: 'TEST_CASE',
|
|
454
|
+
options: [
|
|
455
|
+
{ index: 1, name: 'Smoke', archived: false },
|
|
456
|
+
{ index: 2, name: 'Regression', archived: false },
|
|
457
|
+
{ index: 3, name: 'Performance', archived: false }
|
|
458
|
+
],
|
|
459
|
+
archived: false
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**Available Custom Field Types:**
|
|
465
|
+
- `CHECKBOX` - Checkbox
|
|
466
|
+
- `NUMBER` - Number
|
|
467
|
+
- `DECIMAL` - Decimal number
|
|
468
|
+
- `SINGLE_LINE_TEXT` - Single-line text
|
|
469
|
+
- `MULTI_LINE_TEXT` - Multi-line text
|
|
470
|
+
- `SINGLE_CHOICE_SELECT_LIST` - Single-choice select list
|
|
471
|
+
- `MULTI_CHOICE_SELECT_LIST` - Multi-choice select list
|
|
472
|
+
- `USER_LIST` - User picker
|
|
473
|
+
- `DATE` - Date picker
|
|
474
|
+
|
|
475
|
+
**Available Categories:**
|
|
476
|
+
- `TEST_CASE` - Custom field for test cases
|
|
477
|
+
- `TEST_PLAN` - Custom field for test plans
|
|
478
|
+
- `TEST_RUN` - Custom field for test cycles (test runs)
|
|
479
|
+
- `TEST_STEP` - Custom field for test steps
|
|
480
|
+
|
|
481
|
+
### Create Test Case Version
|
|
482
|
+
|
|
483
|
+
Create a new version of an existing test case. **Note:** When a new version is created, the `testCaseId` changes for that test case.
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
// First, get the test case to find its numeric ID
|
|
487
|
+
const testCase = await api.TestCase.getTestCase({ testCaseKey: 'PROJ-T1' });
|
|
488
|
+
const testCaseId = testCase.id; // Numeric ID, not the key
|
|
489
|
+
|
|
490
|
+
// Create a new version
|
|
491
|
+
const newVersion = await api.Private.createTestCaseVersion(
|
|
492
|
+
'user@example.com',
|
|
493
|
+
'jira-api-token',
|
|
494
|
+
'https://your-instance.atlassian.net',
|
|
495
|
+
testCaseId, // Numeric test case ID
|
|
496
|
+
10017 // Project ID or key
|
|
497
|
+
);
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Important Notes:**
|
|
501
|
+
- The `testCaseId` must be the numeric ID, not the test case key (e.g., `PROJ-T1`)
|
|
502
|
+
- Use `api.TestCase.getTestCase()` to get the numeric ID from a test case key
|
|
503
|
+
- If a new version already exists, the API will return a 409 Conflict error
|
|
504
|
+
- The test case ID changes after creating a new version
|
|
505
|
+
|
|
506
|
+
### Error Handling for Private API
|
|
507
|
+
|
|
508
|
+
Private API methods use the same error types as the public API:
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
try {
|
|
512
|
+
await api.Private.createCustomField(...);
|
|
513
|
+
} catch (error) {
|
|
514
|
+
if (error instanceof Zephyr.BadRequestError) {
|
|
515
|
+
console.log('Invalid request parameters');
|
|
516
|
+
} else if (error instanceof Zephyr.UnauthorizedError) {
|
|
517
|
+
console.log('Authentication failed - check your credentials');
|
|
518
|
+
} else if (error instanceof Zephyr.ForbiddenError) {
|
|
519
|
+
console.log('Insufficient permissions');
|
|
520
|
+
} else if (error instanceof Zephyr.NotFoundError) {
|
|
521
|
+
console.log('Resource not found');
|
|
522
|
+
} else if (error instanceof Zephyr.ServerError) {
|
|
523
|
+
if (error.status === 409) {
|
|
524
|
+
console.log('Conflict - version already exists');
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
373
530
|
## Custom Fields
|
|
374
531
|
|
|
375
532
|
Custom fields are supported as flexible key-value pairs:
|
|
@@ -663,7 +820,7 @@ The `All` group provides a single point of access to all API methods across all
|
|
|
663
820
|
|
|
664
821
|
## License
|
|
665
822
|
|
|
666
|
-
|
|
823
|
+
UNLICENSED - Copyright Adaptavist 2025 (c) All rights reserved
|
|
667
824
|
|
|
668
825
|
## Support
|
|
669
826
|
|
|
@@ -675,3 +832,34 @@ For issues, questions, or contributions, please refer to the project repository
|
|
|
675
832
|
- **Zephyr API Documentation**: https://support.smartbear.com/zephyr-scale-cloud/api-docs/v2/
|
|
676
833
|
- **ScriptRunner Connect Documentation**: https://docs.adaptavist.com/src/latest/
|
|
677
834
|
|
|
835
|
+
## Changelog
|
|
836
|
+
|
|
837
|
+
### 1.1.0
|
|
838
|
+
|
|
839
|
+
- **Added**: Private API group with support for unofficial Zephyr endpoints
|
|
840
|
+
- `getContextJwt()` - Retrieve Jira Context JWT token for private API authentication
|
|
841
|
+
- `createCustomField()` - Create custom fields for test cases, test plans, test runs, and test steps
|
|
842
|
+
- `createTestCaseVersion()` - Create new test case versions
|
|
843
|
+
- **Added**: Type definitions for private API requests (`CreatePrivateCustomFieldRequest`, `PrivateCustomFieldType`, `PrivateCustomFieldCategory`, etc.)
|
|
844
|
+
- **Warning**: Private API methods are not officially supported and may change without notice
|
|
845
|
+
|
|
846
|
+
### 1.0.1
|
|
847
|
+
|
|
848
|
+
- **Added**: Comprehensive JSDoc comments with API endpoint descriptions and links to official documentation
|
|
849
|
+
- **Added**: Single import option via default export for convenient usage
|
|
850
|
+
- **Changed**: Removed `region` parameter from `createZephyrApi` - base URL now configured in Generic Connector
|
|
851
|
+
- **Improved**: Error handling to support both `BadRequestError` and `NotFoundError` in test examples
|
|
852
|
+
- **Improved**: Type safety and IntelliSense support throughout the API
|
|
853
|
+
|
|
854
|
+
### 1.0.0
|
|
855
|
+
|
|
856
|
+
- **Initial Release**: Complete Managed API wrapper for Zephyr Cloud REST API v2
|
|
857
|
+
- **Added**: Full support for all Zephyr API endpoints (Test Cases, Test Cycles, Test Plans, Test Executions, etc.)
|
|
858
|
+
- **Added**: Type-safe TypeScript definitions for all API operations
|
|
859
|
+
- **Added**: Hierarchical API structure matching ScriptRunner Connect conventions
|
|
860
|
+
- **Added**: Automatic rate limiting retry with exponential backoff
|
|
861
|
+
- **Added**: Support for both API Connection and OAuth token authentication
|
|
862
|
+
- **Added**: Pagination helpers (`getAllPages`, `getAllPagesCursor`)
|
|
863
|
+
- **Added**: Error strategy builder for advanced error handling
|
|
864
|
+
- **Added**: Comprehensive error types compatible with Commons Core
|
|
865
|
+
|