bitbucket-data-center-client 1.0.0 → 1.0.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.
- package/README.md +21 -449
- package/dist/client.d.ts +98 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +201 -0
- package/dist/client.js.map +1 -1
- package/dist/types.d.ts +664 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/package.json +14 -17
- package/BitbucketServerSwagger.json +0 -67522
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
# Bitbucket Data Center Client
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🔒 **Type-safe**: Full TypeScript support with comprehensive type definitions
|
|
8
|
-
- 🚀 **Simple**: Clean, intuitive API design
|
|
9
|
-
- 📦 **Lightweight**: Minimal dependencies (only axios)
|
|
10
|
-
- 🎯 **Complete**: Covers users, projects, repositories, and pull requests operations
|
|
3
|
+
TypeScript client for Bitbucket Server/Data Center REST API.
|
|
11
4
|
|
|
12
5
|
## Installation
|
|
13
6
|
|
|
@@ -15,460 +8,49 @@ A TypeScript client library for Bitbucket Server/Data Center REST API. This libr
|
|
|
15
8
|
npm install bitbucket-data-center-client
|
|
16
9
|
```
|
|
17
10
|
|
|
18
|
-
##
|
|
11
|
+
## Usage
|
|
19
12
|
|
|
20
13
|
```typescript
|
|
21
14
|
import { BitbucketClient } from 'bitbucket-data-center-client';
|
|
22
15
|
|
|
23
|
-
// Initialize the client
|
|
24
16
|
const client = new BitbucketClient({
|
|
25
17
|
token: 'your-personal-access-token',
|
|
26
18
|
baseUrl: 'https://bitbucket.example.com'
|
|
27
19
|
});
|
|
28
20
|
|
|
29
|
-
// Get user profile
|
|
30
|
-
const user = await client.getUserProfile({ username: 'john.doe' });
|
|
31
|
-
console.log(user.displayName);
|
|
32
|
-
|
|
33
21
|
// List projects
|
|
34
|
-
const projects = await client.listProjects(
|
|
35
|
-
projects.values.forEach(project => {
|
|
36
|
-
console.log(`${project.key}: ${project.name}`);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Get pull requests in your inbox
|
|
40
|
-
const prs = await client.getInboxPullRequests({ limit: 25 });
|
|
41
|
-
prs.values.forEach(pr => {
|
|
42
|
-
console.log(`PR #${pr.id}: ${pr.title}`);
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Authentication
|
|
47
|
-
|
|
48
|
-
The client uses **Bearer token authentication** with Bitbucket Personal Access Tokens:
|
|
49
|
-
|
|
50
|
-
1. Generate a Personal Access Token in Bitbucket Server:
|
|
51
|
-
- Navigate to **Profile → Manage account → Personal access tokens**
|
|
52
|
-
- Create a token with appropriate permissions (e.g., `REPO_READ`, `REPO_WRITE`)
|
|
53
|
-
2. Pass the token and base URL to the client constructor
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
// Simple configuration (most common)
|
|
57
|
-
const client = new BitbucketClient({
|
|
58
|
-
token: process.env.BITBUCKET_TOKEN!,
|
|
59
|
-
baseUrl: process.env.BITBUCKET_URL! // e.g., 'https://bitbucket.example.com'
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Advanced: with custom axios configuration
|
|
63
|
-
const client = new BitbucketClient({
|
|
64
|
-
token: process.env.BITBUCKET_TOKEN!,
|
|
65
|
-
baseUrl: process.env.BITBUCKET_URL!,
|
|
66
|
-
axiosConfig: {
|
|
67
|
-
timeout: 10000,
|
|
68
|
-
headers: {
|
|
69
|
-
'X-Custom-Header': 'value'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## API Reference
|
|
76
|
-
|
|
77
|
-
### User Operations
|
|
78
|
-
|
|
79
|
-
#### Get User Profile
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
const user = await client.getUserProfile({
|
|
83
|
-
username: 'john.doe'
|
|
84
|
-
});
|
|
85
|
-
console.log(user.displayName, user.emailAddress);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
#### Get All Users
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
const users = await client.getAllUsers({
|
|
92
|
-
filter: 'john' // Optional: filter by username, name, or email
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Project Operations
|
|
97
|
-
|
|
98
|
-
#### List Projects
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
const projects = await client.listProjects({
|
|
102
|
-
name: 'MyProject', // Optional: filter by name
|
|
103
|
-
permission: 'PROJECT_WRITE', // Optional: filter by permission
|
|
104
|
-
start: 0, // Optional: pagination start
|
|
105
|
-
limit: 25 // Optional: page size
|
|
106
|
-
});
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Repository Operations
|
|
110
|
-
|
|
111
|
-
#### List Repositories
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
const repos = await client.listRepositories({
|
|
115
|
-
projectKey: 'PROJ'
|
|
116
|
-
});
|
|
117
|
-
repos.values.forEach(repo => {
|
|
118
|
-
console.log(`${repo.slug}: ${repo.name}`);
|
|
119
|
-
});
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Pull Request Operations
|
|
123
|
-
|
|
124
|
-
#### Get Inbox Pull Requests
|
|
125
|
-
|
|
126
|
-
Get all PRs where you're assigned as a reviewer:
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
const prs = await client.getInboxPullRequests({
|
|
130
|
-
start: 0,
|
|
131
|
-
limit: 25
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
#### Get Pull Request Details
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
const pr = await client.getPullRequest({
|
|
139
|
-
projectKey: 'PROJ',
|
|
140
|
-
repositorySlug: 'my-repo',
|
|
141
|
-
pullRequestId: 123
|
|
142
|
-
});
|
|
143
|
-
console.log(pr.title, pr.author?.user.displayName);
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
#### Get Pull Request Changes
|
|
147
|
-
|
|
148
|
-
Get list of changed files:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
const changes = await client.getPullRequestChanges({
|
|
152
|
-
projectKey: 'PROJ',
|
|
153
|
-
repositorySlug: 'my-repo',
|
|
154
|
-
pullRequestId: 123
|
|
155
|
-
});
|
|
156
|
-
changes.values.forEach(change => {
|
|
157
|
-
console.log(`${change.type}: ${change.path?.toString}`);
|
|
158
|
-
});
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
#### Get Pull Request Diff
|
|
162
|
-
|
|
163
|
-
Get diff for entire PR or specific file:
|
|
164
|
-
|
|
165
|
-
```typescript
|
|
166
|
-
// Full PR diff (text format)
|
|
167
|
-
const textDiff = await client.getPullRequestDiff({
|
|
168
|
-
projectKey: 'PROJ',
|
|
169
|
-
repositorySlug: 'my-repo',
|
|
170
|
-
pullRequestId: 123,
|
|
171
|
-
format: 'text'
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// Structured diff for specific file
|
|
175
|
-
const structuredDiff = await client.getPullRequestDiff({
|
|
176
|
-
projectKey: 'PROJ',
|
|
177
|
-
repositorySlug: 'my-repo',
|
|
178
|
-
pullRequestId: 123,
|
|
179
|
-
path: 'src/index.ts',
|
|
180
|
-
format: 'json',
|
|
181
|
-
contextLines: 3
|
|
182
|
-
});
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
#### Get File Diff with Line Numbers
|
|
186
|
-
|
|
187
|
-
Get structured line-by-line diff for a specific file:
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
const diff = await client.getPullRequestFileDiff({
|
|
191
|
-
projectKey: 'PROJ',
|
|
192
|
-
repositorySlug: 'my-repo',
|
|
193
|
-
pullRequestId: 123,
|
|
194
|
-
path: 'src/main.ts',
|
|
195
|
-
contextLines: 10
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Access hunks and segments
|
|
199
|
-
diff.diffs[0]?.hunks?.forEach(hunk => {
|
|
200
|
-
hunk.segments.forEach(segment => {
|
|
201
|
-
segment.lines.forEach(line => {
|
|
202
|
-
console.log(`Line ${line.destination}: ${line.line}`);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
```
|
|
22
|
+
const projects = await client.listProjects();
|
|
207
23
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
Get PR activity (comments, approvals, etc.):
|
|
211
|
-
|
|
212
|
-
```typescript
|
|
213
|
-
const activities = await client.getPullRequestActivities({
|
|
24
|
+
// Browse repository contents
|
|
25
|
+
const contents = await client.browse({
|
|
214
26
|
projectKey: 'PROJ',
|
|
215
27
|
repositorySlug: 'my-repo',
|
|
216
|
-
|
|
217
|
-
activityTypes: ['COMMENTED', 'REVIEW_COMMENTED'], // Optional filter
|
|
218
|
-
start: 0,
|
|
219
|
-
limit: 25
|
|
28
|
+
path: 'src'
|
|
220
29
|
});
|
|
221
30
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
});
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
#### Add Pull Request Comment
|
|
228
|
-
|
|
229
|
-
Add general, file, or line comment:
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
// General comment
|
|
233
|
-
await client.addPullRequestComment({
|
|
31
|
+
// Get raw file content
|
|
32
|
+
const file = await client.getRawContent({
|
|
234
33
|
projectKey: 'PROJ',
|
|
235
34
|
repositorySlug: 'my-repo',
|
|
236
|
-
|
|
237
|
-
text: 'Looks good to me!'
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// File-level comment
|
|
241
|
-
await client.addPullRequestComment({
|
|
242
|
-
projectKey: 'PROJ',
|
|
243
|
-
repositorySlug: 'my-repo',
|
|
244
|
-
pullRequestId: 123,
|
|
245
|
-
text: 'This file needs refactoring',
|
|
246
|
-
path: 'src/main.ts'
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// Inline comment on specific line
|
|
250
|
-
await client.addPullRequestComment({
|
|
251
|
-
projectKey: 'PROJ',
|
|
252
|
-
repositorySlug: 'my-repo',
|
|
253
|
-
pullRequestId: 123,
|
|
254
|
-
text: 'Consider using const here',
|
|
255
|
-
path: 'src/main.ts',
|
|
256
|
-
line: 42,
|
|
257
|
-
lineType: 'ADDED',
|
|
258
|
-
fileType: 'TO'
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// Reply to a comment
|
|
262
|
-
await client.addPullRequestComment({
|
|
263
|
-
projectKey: 'PROJ',
|
|
264
|
-
repositorySlug: 'my-repo',
|
|
265
|
-
pullRequestId: 123,
|
|
266
|
-
text: 'Good catch!',
|
|
267
|
-
parentId: 456
|
|
35
|
+
path: 'package.json'
|
|
268
36
|
});
|
|
269
37
|
```
|
|
270
38
|
|
|
271
|
-
|
|
39
|
+
## Available Methods
|
|
272
40
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
#### Update Review Status
|
|
284
|
-
|
|
285
|
-
Approve, request changes, or remove approval:
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
// Approve PR
|
|
289
|
-
await client.updateReviewStatus({
|
|
290
|
-
projectKey: 'PROJ',
|
|
291
|
-
repositorySlug: 'my-repo',
|
|
292
|
-
pullRequestId: 123,
|
|
293
|
-
status: 'APPROVED'
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
// Request changes
|
|
297
|
-
await client.updateReviewStatus({
|
|
298
|
-
projectKey: 'PROJ',
|
|
299
|
-
repositorySlug: 'my-repo',
|
|
300
|
-
pullRequestId: 123,
|
|
301
|
-
status: 'NEEDS_WORK'
|
|
302
|
-
});
|
|
41
|
+
| Category | Methods |
|
|
42
|
+
|----------|---------|
|
|
43
|
+
| Users | `getUserProfile`, `getAllUsers` |
|
|
44
|
+
| Projects | `listProjects` |
|
|
45
|
+
| Repositories | `listRepositories`, `getRepository`, `browse`, `getRawContent` |
|
|
46
|
+
| Pull Requests | `getInboxPullRequests`, `getDashboardPullRequests`, `getPullRequest`, `createPullRequest`, `getRequiredReviewers` |
|
|
47
|
+
| PR Changes | `getPullRequestChanges`, `getPullRequestDiff`, `getPullRequestFileDiff` |
|
|
48
|
+
| PR Comments | `addPullRequestComment`, `deletePullRequestComment`, `getPullRequestActivities` |
|
|
49
|
+
| PR Review | `updateReviewStatus`, `addPullRequestCommentReaction`, `removePullRequestCommentReaction` |
|
|
303
50
|
|
|
304
|
-
|
|
305
|
-
await client.updateReviewStatus({
|
|
306
|
-
projectKey: 'PROJ',
|
|
307
|
-
repositorySlug: 'my-repo',
|
|
308
|
-
pullRequestId: 123,
|
|
309
|
-
status: 'UNAPPROVED'
|
|
310
|
-
});
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
#### Add/Remove Comment Reactions
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
// Add reaction
|
|
317
|
-
await client.addPullRequestCommentReaction({
|
|
318
|
-
projectKey: 'PROJ',
|
|
319
|
-
repositorySlug: 'my-repo',
|
|
320
|
-
pullRequestId: 123,
|
|
321
|
-
commentId: 456,
|
|
322
|
-
emoticon: 'thumbsup' // thumbsup, thumbsdown, heart, thinking_face, laughing
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// Remove reaction
|
|
326
|
-
await client.removePullRequestCommentReaction({
|
|
327
|
-
projectKey: 'PROJ',
|
|
328
|
-
repositorySlug: 'my-repo',
|
|
329
|
-
pullRequestId: 123,
|
|
330
|
-
commentId: 456,
|
|
331
|
-
emoticon: 'thumbsup'
|
|
332
|
-
});
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
## Complete Example: PR Review Workflow
|
|
336
|
-
|
|
337
|
-
```typescript
|
|
338
|
-
import { BitbucketClient } from 'bitbucket-data-center-client';
|
|
339
|
-
|
|
340
|
-
const client = new BitbucketClient({
|
|
341
|
-
token: process.env.BITBUCKET_TOKEN!,
|
|
342
|
-
baseUrl: process.env.BITBUCKET_URL!
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
async function reviewPullRequest() {
|
|
346
|
-
// 1. Get PRs in your inbox
|
|
347
|
-
const inbox = await client.getInboxPullRequests({ limit: 10 });
|
|
348
|
-
const pr = inbox.values[0];
|
|
349
|
-
|
|
350
|
-
if (!pr) {
|
|
351
|
-
console.log('No PRs to review');
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
console.log(`Reviewing: ${pr.title}`);
|
|
356
|
-
|
|
357
|
-
// 2. Get PR details
|
|
358
|
-
const projectKey = pr.toRef.repository.project.key;
|
|
359
|
-
const repositorySlug = pr.toRef.repository.slug;
|
|
360
|
-
const pullRequestId = pr.id;
|
|
361
|
-
|
|
362
|
-
// 3. Get changed files
|
|
363
|
-
const changes = await client.getPullRequestChanges({
|
|
364
|
-
projectKey,
|
|
365
|
-
repositorySlug,
|
|
366
|
-
pullRequestId
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
console.log(`Changed files: ${changes.values.length}`);
|
|
370
|
-
|
|
371
|
-
// 4. Review each file
|
|
372
|
-
for (const change of changes.values) {
|
|
373
|
-
const path = change.path?.toString;
|
|
374
|
-
if (!path) continue;
|
|
375
|
-
|
|
376
|
-
// Get file diff
|
|
377
|
-
const diff = await client.getPullRequestFileDiff({
|
|
378
|
-
projectKey,
|
|
379
|
-
repositorySlug,
|
|
380
|
-
pullRequestId,
|
|
381
|
-
path
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
// Check for issues and add comments
|
|
385
|
-
diff.diffs[0]?.hunks?.forEach(hunk => {
|
|
386
|
-
hunk.segments.forEach(segment => {
|
|
387
|
-
if (segment.type === 'ADDED') {
|
|
388
|
-
segment.lines.forEach(line => {
|
|
389
|
-
if (line.line?.includes('console.log')) {
|
|
390
|
-
// Add inline comment
|
|
391
|
-
client.addPullRequestComment({
|
|
392
|
-
projectKey,
|
|
393
|
-
repositorySlug,
|
|
394
|
-
pullRequestId,
|
|
395
|
-
text: 'Please remove console.log before merging',
|
|
396
|
-
path,
|
|
397
|
-
line: line.destination!,
|
|
398
|
-
lineType: 'ADDED',
|
|
399
|
-
fileType: 'TO'
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// 5. Approve or request changes
|
|
409
|
-
await client.updateReviewStatus({
|
|
410
|
-
projectKey,
|
|
411
|
-
repositorySlug,
|
|
412
|
-
pullRequestId,
|
|
413
|
-
status: 'NEEDS_WORK'
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
console.log('Review complete!');
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
reviewPullRequest().catch(console.error);
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
## Type Definitions
|
|
423
|
-
|
|
424
|
-
This library exports comprehensive TypeScript types for all API entities:
|
|
425
|
-
|
|
426
|
-
```typescript
|
|
427
|
-
import type {
|
|
428
|
-
// Common
|
|
429
|
-
PaginatedResponse,
|
|
430
|
-
// User & Project
|
|
431
|
-
RestUser,
|
|
432
|
-
RestProject,
|
|
433
|
-
RestRepository,
|
|
434
|
-
// Pull Request
|
|
435
|
-
RestPullRequest,
|
|
436
|
-
InboxPullRequest,
|
|
437
|
-
RestComment,
|
|
438
|
-
RestChange,
|
|
439
|
-
DiffResponse,
|
|
440
|
-
RestPullRequestActivity,
|
|
441
|
-
// Method parameters
|
|
442
|
-
GetPullRequestParams,
|
|
443
|
-
AddPullRequestCommentParams,
|
|
444
|
-
UpdateReviewStatusParams,
|
|
445
|
-
// ... and many more
|
|
446
|
-
} from 'bitbucket-data-center-client';
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
See [types.ts](./src/types.ts) for the complete list of exported types.
|
|
450
|
-
|
|
451
|
-
## API Documentation
|
|
452
|
-
|
|
453
|
-
This library is based on the official Bitbucket Server REST API. See `BitbucketServerSwagger.json` in this package for the complete API specification.
|
|
454
|
-
|
|
455
|
-
## Error Handling
|
|
51
|
+
## Authentication
|
|
456
52
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
```typescript
|
|
460
|
-
try {
|
|
461
|
-
const pr = await client.getPullRequest({
|
|
462
|
-
projectKey: 'PROJ',
|
|
463
|
-
repositorySlug: 'my-repo',
|
|
464
|
-
pullRequestId: 999
|
|
465
|
-
});
|
|
466
|
-
} catch (error) {
|
|
467
|
-
if (axios.isAxiosError(error)) {
|
|
468
|
-
console.error('API Error:', error.response?.data);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
```
|
|
53
|
+
Generate a Personal Access Token in Bitbucket: **Profile → Manage account → Personal access tokens**
|
|
472
54
|
|
|
473
55
|
## Requirements
|
|
474
56
|
|
|
@@ -478,13 +60,3 @@ try {
|
|
|
478
60
|
## License
|
|
479
61
|
|
|
480
62
|
MIT
|
|
481
|
-
|
|
482
|
-
## Contributing
|
|
483
|
-
|
|
484
|
-
Contributions are welcome! Please open an issue or submit a pull request.
|
|
485
|
-
|
|
486
|
-
## Support
|
|
487
|
-
|
|
488
|
-
For issues and questions:
|
|
489
|
-
- GitHub Issues: [your-repo-url]
|
|
490
|
-
- Documentation: See inline JSDoc comments in the source code
|
package/dist/client.d.ts
CHANGED
|
@@ -1,21 +1,118 @@
|
|
|
1
|
-
import type { AddPullRequestCommentParams, AddPullRequestCommentReactionParams, BitbucketClientConfig, ChangesResponse, DeletePullRequestCommentParams, DiffResponse, GetAllUsersParams, GetInboxPullRequestsParams, GetPullRequestActivitiesParams, GetPullRequestChangesParams, GetPullRequestDiffParams, GetPullRequestFileDiffParams, GetPullRequestParams, GetUserProfileParams, InboxPullRequest, ListProjectsParams, ListRepositoriesParams, PaginatedResponse, RemovePullRequestCommentReactionParams, RepositoriesResponse, RestComment, RestProject, RestPullRequest, RestPullRequestActivityApiResponse, RestPullRequestParticipant, RestUser, RestUserReaction, UpdateReviewStatusParams } from './types.js';
|
|
1
|
+
import type { AddPullRequestCommentParams, AddPullRequestCommentReactionParams, BitbucketClientConfig, BrowseParams, BrowseResponse, ChangesResponse, CheckRepositoryPermissionsParams, CreatePullRequestParams, DeletePullRequestCommentParams, DiffResponse, GetAllUsersParams, GetDashboardPullRequestsParams, GetRawContentParams, GetInboxPullRequestsParams, GetPullRequestActivitiesParams, GetPullRequestChangesParams, GetPullRequestDiffParams, GetPullRequestFileDiffParams, GetPullRequestParams, GetRepositoryParams, GetRequiredReviewersParams, GetUserProfileParams, InboxPullRequest, ListProjectsParams, ListRepositoriesParams, PaginatedResponse, RemovePullRequestCommentReactionParams, RepositoriesResponse, RepositoryPermissions, RestComment, RestProject, RestPullRequest, RestPullRequestActivityApiResponse, RestPullRequestParticipant, RestRepository, RestUser, RestUserReaction, UpdateReviewStatusParams } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bitbucket Server/Data Center API client.
|
|
4
|
+
* Provides typed methods for interacting with Bitbucket Server REST API.
|
|
5
|
+
*/
|
|
2
6
|
export declare class BitbucketClient {
|
|
3
7
|
private client;
|
|
4
8
|
constructor(config: BitbucketClientConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Get a Bitbucket Server user profile by username
|
|
11
|
+
*/
|
|
5
12
|
getUserProfile(params: GetUserProfileParams): Promise<RestUser>;
|
|
13
|
+
/**
|
|
14
|
+
* Get all users, optionally filtered by search term
|
|
15
|
+
*/
|
|
6
16
|
getAllUsers(params?: GetAllUsersParams): Promise<PaginatedResponse<RestUser>>;
|
|
17
|
+
/**
|
|
18
|
+
* List projects, optionally filtered by name or permission
|
|
19
|
+
*/
|
|
7
20
|
listProjects(params?: ListProjectsParams): Promise<PaginatedResponse<RestProject>>;
|
|
21
|
+
/**
|
|
22
|
+
* List all repositories in a project
|
|
23
|
+
*/
|
|
8
24
|
listRepositories(params: ListRepositoriesParams): Promise<RepositoriesResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Get a repository by project key and slug
|
|
27
|
+
*/
|
|
28
|
+
getRepository(params: GetRepositoryParams): Promise<RestRepository>;
|
|
29
|
+
/**
|
|
30
|
+
* Get pull requests in the authenticated user's inbox (where they are assigned as reviewer)
|
|
31
|
+
*/
|
|
9
32
|
getInboxPullRequests(params?: GetInboxPullRequestsParams): Promise<PaginatedResponse<InboxPullRequest>>;
|
|
33
|
+
/**
|
|
34
|
+
* Get pull requests from the user's dashboard.
|
|
35
|
+
* Can filter by role (AUTHOR, REVIEWER, PARTICIPANT), state, and more.
|
|
36
|
+
*/
|
|
37
|
+
getDashboardPullRequests(params?: GetDashboardPullRequestsParams): Promise<PaginatedResponse<RestPullRequest>>;
|
|
38
|
+
/**
|
|
39
|
+
* Get pull request details (title, description, author, branches, etc.)
|
|
40
|
+
*/
|
|
10
41
|
getPullRequest(params: GetPullRequestParams): Promise<RestPullRequest>;
|
|
42
|
+
/**
|
|
43
|
+
* Create a new pull request.
|
|
44
|
+
* Supports both same-repo PRs (default) and cross-repo PRs (when fromRepositorySlug is provided).
|
|
45
|
+
* Branch names are automatically converted to full refs (e.g., "main" → "refs/heads/main").
|
|
46
|
+
*/
|
|
47
|
+
createPullRequest(params: CreatePullRequestParams): Promise<RestPullRequest>;
|
|
48
|
+
/**
|
|
49
|
+
* Get all changed files in a pull request
|
|
50
|
+
*/
|
|
11
51
|
getPullRequestChanges(params: GetPullRequestChangesParams): Promise<ChangesResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Get structured line-by-line diff for a specific file in a pull request
|
|
54
|
+
*/
|
|
12
55
|
getPullRequestFileDiff(params: GetPullRequestFileDiffParams): Promise<DiffResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Get diff for a pull request (or specific file).
|
|
58
|
+
* When path is empty or undefined, returns the full PR diff.
|
|
59
|
+
* Format controls the response type:
|
|
60
|
+
* - 'text': Raw diff as plain text string
|
|
61
|
+
* - 'json': Structured diff object (DiffResponse)
|
|
62
|
+
*/
|
|
13
63
|
getPullRequestDiff(params: GetPullRequestDiffParams): Promise<string | DiffResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Get activity on a pull request (comments, approvals, merges, reviews, updates)
|
|
66
|
+
*/
|
|
14
67
|
getPullRequestActivities(params: GetPullRequestActivitiesParams): Promise<PaginatedResponse<RestPullRequestActivityApiResponse>>;
|
|
68
|
+
/**
|
|
69
|
+
* Add a comment to a pull request (supports general comments, replies, and inline file/line comments)
|
|
70
|
+
*/
|
|
15
71
|
addPullRequestComment(params: AddPullRequestCommentParams): Promise<RestComment>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a pull request comment. Returns void on success (HTTP 204).
|
|
74
|
+
* Anyone can delete their own comment. Only REPO_ADMIN can delete others' comments.
|
|
75
|
+
* Comments with replies cannot be deleted.
|
|
76
|
+
*/
|
|
16
77
|
deletePullRequestComment(params: DeletePullRequestCommentParams): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Update review status for a pull request (approve, request changes, or remove approval)
|
|
80
|
+
*/
|
|
17
81
|
updateReviewStatus(params: UpdateReviewStatusParams): Promise<RestPullRequestParticipant>;
|
|
82
|
+
/**
|
|
83
|
+
* Add an emoticon reaction to a pull request comment
|
|
84
|
+
*/
|
|
18
85
|
addPullRequestCommentReaction(params: AddPullRequestCommentReactionParams): Promise<RestUserReaction>;
|
|
86
|
+
/**
|
|
87
|
+
* Remove an emoticon reaction from a pull request comment
|
|
88
|
+
*/
|
|
19
89
|
removePullRequestCommentReaction(params: RemovePullRequestCommentReactionParams): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Get the list of required/default reviewers for a pull request.
|
|
92
|
+
* Returns users who would be automatically assigned as reviewers based on configured rules.
|
|
93
|
+
* Note: Default reviewers are NOT auto-added when creating PRs via API - you must
|
|
94
|
+
* fetch them with this method and pass them to createPullRequest().
|
|
95
|
+
* Branch names are automatically converted to full refs (e.g., "main" → "refs/heads/main").
|
|
96
|
+
* Use getRepository() to obtain the repositoryId.
|
|
97
|
+
*/
|
|
98
|
+
getRequiredReviewers(params: GetRequiredReviewersParams): Promise<RestUser[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Browse repository contents at a given path (structured JSON response).
|
|
101
|
+
* Returns different response based on path type:
|
|
102
|
+
* - Directory: { children: [...] } with file/folder entries
|
|
103
|
+
* - File: { lines: [...] } with file content
|
|
104
|
+
* Check 'children' in response to determine type.
|
|
105
|
+
*/
|
|
106
|
+
browse(params: BrowseParams): Promise<BrowseResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Get raw content from repository (plain text).
|
|
109
|
+
* Returns file content as plain text, or git tree listing for directories.
|
|
110
|
+
*/
|
|
111
|
+
getRawContent(params: GetRawContentParams): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Check repository permissions for the authenticated token.
|
|
114
|
+
* Returns read/write access flags without modifying anything.
|
|
115
|
+
*/
|
|
116
|
+
checkRepositoryPermissions(params: CheckRepositoryPermissionsParams): Promise<RepositoryPermissions>;
|
|
20
117
|
}
|
|
21
118
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,2BAA2B,EAC3B,mCAAmC,EACnC,qBAAqB,EACrB,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,iBAAiB,EACjB,0BAA0B,EAC1B,8BAA8B,EAC9B,2BAA2B,EAC3B,wBAAwB,EACxB,4BAA4B,EAC5B,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,sCAAsC,EACtC,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,eAAe,E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