@atlassian-dc-mcp/bitbucket 0.11.2 → 0.12.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/CHANGELOG.md +11 -0
- package/README.md +12 -0
- package/build/__tests__/bitbucket-service.test.js +92 -0
- package/build/__tests__/bitbucket-service.test.js.map +1 -1
- package/build/bitbucket-service.d.ts +19 -0
- package/build/bitbucket-service.d.ts.map +1 -1
- package/build/bitbucket-service.js +35 -0
- package/build/bitbucket-service.js.map +1 -1
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/bitbucket-service.test.ts +125 -0
- package/src/bitbucket-service.ts +46 -0
- package/src/index.ts +10 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1507,6 +1507,131 @@ describe('BitbucketService', () => {
|
|
|
1507
1507
|
});
|
|
1508
1508
|
});
|
|
1509
1509
|
|
|
1510
|
+
describe('getDashboardPullRequests', () => {
|
|
1511
|
+
const { request: mockRequest } = require('../bitbucket-client/core/request.js');
|
|
1512
|
+
|
|
1513
|
+
it('should default to AUTHOR role and limit of 10', async () => {
|
|
1514
|
+
const mockData = {
|
|
1515
|
+
values: [
|
|
1516
|
+
{ id: 1, title: 'PR 1', state: 'OPEN' },
|
|
1517
|
+
{ id: 2, title: 'PR 2', state: 'OPEN' }
|
|
1518
|
+
],
|
|
1519
|
+
size: 2,
|
|
1520
|
+
isLastPage: true
|
|
1521
|
+
};
|
|
1522
|
+
mockRequest.mockResolvedValue(mockData);
|
|
1523
|
+
|
|
1524
|
+
const result = await bitbucketService.getDashboardPullRequests();
|
|
1525
|
+
|
|
1526
|
+
expect(result.success).toBe(true);
|
|
1527
|
+
expect(result.data).toBe(mockData);
|
|
1528
|
+
expect(mockRequest).toHaveBeenCalledWith(
|
|
1529
|
+
expect.any(Object),
|
|
1530
|
+
{
|
|
1531
|
+
method: 'GET',
|
|
1532
|
+
url: '/api/1.0/dashboard/pull-requests',
|
|
1533
|
+
query: {
|
|
1534
|
+
'role': 'AUTHOR',
|
|
1535
|
+
'state': 'OPEN',
|
|
1536
|
+
'closedSince': undefined,
|
|
1537
|
+
'order': 'NEWEST',
|
|
1538
|
+
'start': undefined,
|
|
1539
|
+
'limit': 10,
|
|
1540
|
+
},
|
|
1541
|
+
errors: {
|
|
1542
|
+
401: 'The currently authenticated user is not permitted to access the dashboard.',
|
|
1543
|
+
},
|
|
1544
|
+
}
|
|
1545
|
+
);
|
|
1546
|
+
});
|
|
1547
|
+
|
|
1548
|
+
it('should get dashboard PRs filtered by role and state', async () => {
|
|
1549
|
+
const mockData = {
|
|
1550
|
+
values: [{ id: 1, title: 'My PR', state: 'OPEN' }],
|
|
1551
|
+
size: 1,
|
|
1552
|
+
isLastPage: true
|
|
1553
|
+
};
|
|
1554
|
+
mockRequest.mockResolvedValue(mockData);
|
|
1555
|
+
|
|
1556
|
+
const result = await bitbucketService.getDashboardPullRequests(
|
|
1557
|
+
'REVIEWER',
|
|
1558
|
+
'OPEN',
|
|
1559
|
+
undefined,
|
|
1560
|
+
'NEWEST',
|
|
1561
|
+
0,
|
|
1562
|
+
5
|
|
1563
|
+
);
|
|
1564
|
+
|
|
1565
|
+
expect(result.success).toBe(true);
|
|
1566
|
+
expect(result.data).toBe(mockData);
|
|
1567
|
+
expect(mockRequest).toHaveBeenCalledWith(
|
|
1568
|
+
expect.any(Object),
|
|
1569
|
+
{
|
|
1570
|
+
method: 'GET',
|
|
1571
|
+
url: '/api/1.0/dashboard/pull-requests',
|
|
1572
|
+
query: {
|
|
1573
|
+
'role': 'REVIEWER',
|
|
1574
|
+
'state': 'OPEN',
|
|
1575
|
+
'closedSince': undefined,
|
|
1576
|
+
'order': 'NEWEST',
|
|
1577
|
+
'start': 0,
|
|
1578
|
+
'limit': 5,
|
|
1579
|
+
},
|
|
1580
|
+
errors: {
|
|
1581
|
+
401: 'The currently authenticated user is not permitted to access the dashboard.',
|
|
1582
|
+
},
|
|
1583
|
+
}
|
|
1584
|
+
);
|
|
1585
|
+
});
|
|
1586
|
+
|
|
1587
|
+
it('should get dashboard PRs with closedSince filter', async () => {
|
|
1588
|
+
const mockData = {
|
|
1589
|
+
values: [{ id: 3, title: 'Merged PR', state: 'MERGED' }],
|
|
1590
|
+
size: 1,
|
|
1591
|
+
isLastPage: true
|
|
1592
|
+
};
|
|
1593
|
+
mockRequest.mockResolvedValue(mockData);
|
|
1594
|
+
|
|
1595
|
+
const closedSince = 1700000000000;
|
|
1596
|
+
const result = await bitbucketService.getDashboardPullRequests(
|
|
1597
|
+
'PARTICIPANT',
|
|
1598
|
+
'MERGED',
|
|
1599
|
+
closedSince
|
|
1600
|
+
);
|
|
1601
|
+
|
|
1602
|
+
expect(result.success).toBe(true);
|
|
1603
|
+
expect(result.data).toBe(mockData);
|
|
1604
|
+
expect(mockRequest).toHaveBeenCalledWith(
|
|
1605
|
+
expect.any(Object),
|
|
1606
|
+
{
|
|
1607
|
+
method: 'GET',
|
|
1608
|
+
url: '/api/1.0/dashboard/pull-requests',
|
|
1609
|
+
query: {
|
|
1610
|
+
'role': 'PARTICIPANT',
|
|
1611
|
+
'state': 'MERGED',
|
|
1612
|
+
'closedSince': closedSince,
|
|
1613
|
+
'order': 'NEWEST',
|
|
1614
|
+
'start': undefined,
|
|
1615
|
+
'limit': 10,
|
|
1616
|
+
},
|
|
1617
|
+
errors: {
|
|
1618
|
+
401: 'The currently authenticated user is not permitted to access the dashboard.',
|
|
1619
|
+
},
|
|
1620
|
+
}
|
|
1621
|
+
);
|
|
1622
|
+
});
|
|
1623
|
+
|
|
1624
|
+
it('should handle API errors', async () => {
|
|
1625
|
+
const mockError = new Error('Unauthorized');
|
|
1626
|
+
mockRequest.mockRejectedValue(mockError);
|
|
1627
|
+
|
|
1628
|
+
const result = await bitbucketService.getDashboardPullRequests();
|
|
1629
|
+
|
|
1630
|
+
expect(result.success).toBe(false);
|
|
1631
|
+
expect(result.error).toBe('Unauthorized');
|
|
1632
|
+
});
|
|
1633
|
+
});
|
|
1634
|
+
|
|
1510
1635
|
describe('getInboxPullRequests', () => {
|
|
1511
1636
|
const { request: mockRequest } = require('../bitbucket-client/core/request.js');
|
|
1512
1637
|
|
package/src/bitbucket-service.ts
CHANGED
|
@@ -570,6 +570,44 @@ export class BitbucketService {
|
|
|
570
570
|
);
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
+
/**
|
|
574
|
+
* Get pull requests from the dashboard API (across all repositories)
|
|
575
|
+
* @param role Role filter: AUTHOR (default), REVIEWER, or PARTICIPANT
|
|
576
|
+
* @param state State filter: OPEN (default), DECLINED, or MERGED
|
|
577
|
+
* @param closedSince Optional timestamp (in milliseconds) to filter PRs closed after this date
|
|
578
|
+
* @param order Order: NEWEST (default), OLDEST, or PARTICIPANT
|
|
579
|
+
* @param start Optional pagination start
|
|
580
|
+
* @param limit Pagination limit (default: 10)
|
|
581
|
+
* @returns Promise with dashboard pull requests data
|
|
582
|
+
*/
|
|
583
|
+
async getDashboardPullRequests(
|
|
584
|
+
role: string = 'AUTHOR',
|
|
585
|
+
state: string = 'OPEN',
|
|
586
|
+
closedSince?: number,
|
|
587
|
+
order: string = 'NEWEST',
|
|
588
|
+
start?: number,
|
|
589
|
+
limit: number = 10
|
|
590
|
+
) {
|
|
591
|
+
return handleApiOperation(
|
|
592
|
+
() => __request(OpenAPI, {
|
|
593
|
+
method: 'GET',
|
|
594
|
+
url: '/api/1.0/dashboard/pull-requests',
|
|
595
|
+
query: {
|
|
596
|
+
'role': role,
|
|
597
|
+
'state': state,
|
|
598
|
+
'closedSince': closedSince,
|
|
599
|
+
'order': order,
|
|
600
|
+
'start': start,
|
|
601
|
+
'limit': limit,
|
|
602
|
+
},
|
|
603
|
+
errors: {
|
|
604
|
+
401: 'The currently authenticated user is not permitted to access the dashboard.',
|
|
605
|
+
},
|
|
606
|
+
}),
|
|
607
|
+
'Error fetching dashboard pull requests'
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
|
|
573
611
|
/**
|
|
574
612
|
* Get pull requests from the authenticated user's inbox (PRs awaiting review)
|
|
575
613
|
* @param start Optional pagination start
|
|
@@ -741,6 +779,14 @@ export const bitbucketToolSchemas = {
|
|
|
741
779
|
sourceRepoId: z.string().optional().describe("Optional ID of the repository in which the source ref exists"),
|
|
742
780
|
targetRepoId: z.string().optional().describe("Optional ID of the repository in which the target ref exists")
|
|
743
781
|
},
|
|
782
|
+
getDashboardPullRequests: {
|
|
783
|
+
role: z.enum(['AUTHOR', 'REVIEWER', 'PARTICIPANT']).optional().default('AUTHOR').describe("Filter by the user's role in the PR: AUTHOR (default), REVIEWER, or PARTICIPANT"),
|
|
784
|
+
state: z.enum(['OPEN', 'DECLINED', 'MERGED']).optional().default('OPEN').describe("Filter by PR state: OPEN (default), DECLINED, or MERGED"),
|
|
785
|
+
closedSince: z.number().optional().describe("Timestamp in milliseconds. If state is not OPEN, return only PRs closed after this date"),
|
|
786
|
+
order: z.enum(['NEWEST', 'OLDEST', 'PARTICIPANT']).optional().default('NEWEST').describe("Order of results: NEWEST (default), OLDEST, or PARTICIPANT"),
|
|
787
|
+
start: z.number().optional().describe("Start number for pagination"),
|
|
788
|
+
limit: z.number().optional().default(10).describe("Number of items to return (default: 10)")
|
|
789
|
+
},
|
|
744
790
|
getInboxPullRequests: {
|
|
745
791
|
start: z.number().optional().describe("Start number for the page (inclusive). If not passed, first page is assumed"),
|
|
746
792
|
limit: z.number().optional().default(25).describe("Number of items to return. If not passed, a page size of 25 is used")
|
package/src/index.ts
CHANGED
|
@@ -193,4 +193,14 @@ server.tool(
|
|
|
193
193
|
}
|
|
194
194
|
);
|
|
195
195
|
|
|
196
|
+
server.tool(
|
|
197
|
+
"bitbucket_getDashboardPullRequests",
|
|
198
|
+
"Get pull requests from the Bitbucket dashboard across all repositories. Useful for finding all PRs where you are the author, reviewer, or participant without specifying a project or repository.",
|
|
199
|
+
bitbucketToolSchemas.getDashboardPullRequests,
|
|
200
|
+
async ({ role, state, closedSince, order, start, limit }) => {
|
|
201
|
+
const result = await bitbucketService.getDashboardPullRequests(role, state, closedSince, order, start, limit);
|
|
202
|
+
return formatToolResponse(result);
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
|
|
196
206
|
await connectServer(server);
|