bitbucket-datacenter-api-client 1.1.0 → 1.3.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 +208 -0
- package/dist/index.d.mts +545 -19
- package/dist/index.d.ts +545 -19
- package/dist/index.js +260 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +260 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -15,7 +15,8 @@ interface PaginationParams {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Wrapper returned by Bitbucket paginated list endpoints.
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* Use `values` for the items, `isLastPage` and `nextPageStart` for pagination.
|
|
19
20
|
*/
|
|
20
21
|
interface PagedResponse<T> {
|
|
21
22
|
values: T[];
|
|
@@ -85,6 +86,48 @@ interface ReposParams extends PaginationParams {
|
|
|
85
86
|
permission?: string;
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Represents a Bitbucket Data Center user.
|
|
91
|
+
*/
|
|
92
|
+
interface BitbucketUser {
|
|
93
|
+
name: string;
|
|
94
|
+
emailAddress: string;
|
|
95
|
+
id: number;
|
|
96
|
+
displayName: string;
|
|
97
|
+
active: boolean;
|
|
98
|
+
slug: string;
|
|
99
|
+
type: 'NORMAL' | 'SERVICE';
|
|
100
|
+
links: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A user with an explicit permission on a project.
|
|
104
|
+
*/
|
|
105
|
+
interface BitbucketUserPermission {
|
|
106
|
+
user: BitbucketUser;
|
|
107
|
+
permission: 'PROJECT_READ' | 'PROJECT_WRITE' | 'PROJECT_ADMIN';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Query parameters accepted by `GET /rest/api/latest/users`.
|
|
111
|
+
*
|
|
112
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-users/#api-api-latest-users-get}
|
|
113
|
+
*/
|
|
114
|
+
interface UsersParams extends PaginationParams {
|
|
115
|
+
/** Filter results by display name or username (prefix match) */
|
|
116
|
+
filter?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Query parameters accepted by
|
|
120
|
+
* `GET /rest/api/latest/projects/{key}/permissions/users`.
|
|
121
|
+
*
|
|
122
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-project/#api-api-latest-projects-projectkey-permissions-users-get}
|
|
123
|
+
*/
|
|
124
|
+
interface ProjectUsersParams extends PaginationParams {
|
|
125
|
+
/** Filter results by display name or username (prefix match) */
|
|
126
|
+
filter?: string;
|
|
127
|
+
/** Filter by the permission level on the project */
|
|
128
|
+
permission?: 'PROJECT_READ' | 'PROJECT_WRITE' | 'PROJECT_ADMIN';
|
|
129
|
+
}
|
|
130
|
+
|
|
88
131
|
/** A git ref (branch or tag) as referenced in a pull request. */
|
|
89
132
|
interface BitbucketRef {
|
|
90
133
|
id: string;
|
|
@@ -205,6 +248,167 @@ interface CommitsParams extends PaginationParams {
|
|
|
205
248
|
ignoreMissing?: boolean;
|
|
206
249
|
}
|
|
207
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Represents a git branch in a Bitbucket Data Center repository.
|
|
253
|
+
*/
|
|
254
|
+
interface BitbucketBranch {
|
|
255
|
+
/** Full ref name (e.g., `'refs/heads/main'`) */
|
|
256
|
+
id: string;
|
|
257
|
+
/** Short branch name (e.g., `'main'`) */
|
|
258
|
+
displayId: string;
|
|
259
|
+
type: 'BRANCH';
|
|
260
|
+
/** SHA of the latest commit on this branch */
|
|
261
|
+
latestCommit: string;
|
|
262
|
+
latestChangeset: string;
|
|
263
|
+
/** Whether this is the repository's default branch */
|
|
264
|
+
isDefault: boolean;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Query parameters accepted by
|
|
268
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/branches`.
|
|
269
|
+
*
|
|
270
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-branches-get}
|
|
271
|
+
*/
|
|
272
|
+
interface BranchesParams extends PaginationParams {
|
|
273
|
+
/** Filter branches by name (prefix match) */
|
|
274
|
+
filterText?: string;
|
|
275
|
+
/** Sort order of results */
|
|
276
|
+
orderBy?: 'ALPHABETICAL' | 'MODIFICATION';
|
|
277
|
+
/** Include branch metadata such as ahead/behind counts relative to `base` */
|
|
278
|
+
details?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Base branch or commit to use for ahead/behind comparisons
|
|
281
|
+
* when `details` is `true`
|
|
282
|
+
*/
|
|
283
|
+
base?: string;
|
|
284
|
+
/** Boost exact matches to the top of the results when filtering */
|
|
285
|
+
boostMatches?: boolean;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Represents a git tag in a Bitbucket Data Center repository.
|
|
290
|
+
*/
|
|
291
|
+
interface BitbucketTag {
|
|
292
|
+
/** Full ref name (e.g., `'refs/tags/v1.0.0'`) */
|
|
293
|
+
id: string;
|
|
294
|
+
/** Short tag name (e.g., `'v1.0.0'`) */
|
|
295
|
+
displayId: string;
|
|
296
|
+
type: 'TAG';
|
|
297
|
+
/** SHA of the commit this tag points to */
|
|
298
|
+
latestCommit: string;
|
|
299
|
+
latestChangeset: string;
|
|
300
|
+
/** Tag object SHA (only present for annotated tags) */
|
|
301
|
+
hash?: string;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Query parameters accepted by
|
|
305
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/tags`.
|
|
306
|
+
*
|
|
307
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-tags-get}
|
|
308
|
+
*/
|
|
309
|
+
interface TagsParams extends PaginationParams {
|
|
310
|
+
/** Filter tags by name (prefix match) */
|
|
311
|
+
filterText?: string;
|
|
312
|
+
/** Sort order of results */
|
|
313
|
+
orderBy?: 'ALPHABETICAL' | 'MODIFICATION';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Size information for a Bitbucket repository.
|
|
318
|
+
*
|
|
319
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-sizes-get}
|
|
320
|
+
*/
|
|
321
|
+
interface BitbucketRepositorySize {
|
|
322
|
+
/** Size of the repository in bytes */
|
|
323
|
+
repository: number;
|
|
324
|
+
/** Size of attachments in bytes */
|
|
325
|
+
attachments: number;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** The type of change applied to a file in a pull request. */
|
|
329
|
+
type ChangeType = 'ADD' | 'COPY' | 'DELETE' | 'MODIFY' | 'MOVE' | 'RENAME' | 'UNKNOWN';
|
|
330
|
+
/** The node type of the changed entry. */
|
|
331
|
+
type ChangeNodeType = 'FILE' | 'DIRECTORY' | 'SUBMODULE';
|
|
332
|
+
/** Represents a file path in a Bitbucket change entry. */
|
|
333
|
+
interface BitbucketChangePath {
|
|
334
|
+
/** Path segments (e.g., `['src', 'index.ts']`) */
|
|
335
|
+
components: string[];
|
|
336
|
+
/** Parent directory (e.g., `'src'`) */
|
|
337
|
+
parent: string;
|
|
338
|
+
/** File name (e.g., `'index.ts'`) */
|
|
339
|
+
name: string;
|
|
340
|
+
/** File extension (e.g., `'ts'`) */
|
|
341
|
+
extension: string;
|
|
342
|
+
/** Full path string (e.g., `'src/index.ts'`) */
|
|
343
|
+
toString: string;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Represents a single file change within a Bitbucket Data Center pull request.
|
|
347
|
+
*/
|
|
348
|
+
interface BitbucketChange {
|
|
349
|
+
/** Content ID (SHA) of the file in the destination ref */
|
|
350
|
+
contentId?: string;
|
|
351
|
+
/** Content ID (SHA) of the file in the source ref */
|
|
352
|
+
fromContentId?: string;
|
|
353
|
+
/** Path of the changed file in the destination ref */
|
|
354
|
+
path: BitbucketChangePath;
|
|
355
|
+
/** Original path before a rename or move (only present for `RENAME` and `MOVE`) */
|
|
356
|
+
srcPath?: BitbucketChangePath;
|
|
357
|
+
/** Whether the file has the executable bit set in the destination ref */
|
|
358
|
+
executable: boolean;
|
|
359
|
+
/** Whether the file had the executable bit set in the source ref */
|
|
360
|
+
srcExecutable: boolean;
|
|
361
|
+
percentUnchanged: number;
|
|
362
|
+
type: ChangeType;
|
|
363
|
+
nodeType: ChangeNodeType;
|
|
364
|
+
links: Record<string, unknown>;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Query parameters accepted by
|
|
368
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/changes`.
|
|
369
|
+
*
|
|
370
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-pull-requests/#api-api-latest-projects-projectkey-repos-repositoryslug-pull-requests-pullrequestid-changes-get}
|
|
371
|
+
*/
|
|
372
|
+
interface ChangesParams extends PaginationParams {
|
|
373
|
+
/**
|
|
374
|
+
* When `true`, includes the number of comments for each changed file.
|
|
375
|
+
* @default false
|
|
376
|
+
*/
|
|
377
|
+
withComments?: boolean;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Represents a file entry returned by the last-modified endpoint,
|
|
382
|
+
* showing the path and the commit that last touched it.
|
|
383
|
+
*/
|
|
384
|
+
interface BitbucketLastModifiedEntry {
|
|
385
|
+
/** The file path */
|
|
386
|
+
path: BitbucketChangePath;
|
|
387
|
+
/** The commit that last modified this file */
|
|
388
|
+
latestCommit: BitbucketCommit;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Query parameters accepted by
|
|
392
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/last-modified`.
|
|
393
|
+
*
|
|
394
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-last-modified-get}
|
|
395
|
+
*/
|
|
396
|
+
interface LastModifiedParams extends PaginationParams {
|
|
397
|
+
/** Branch, tag, or commit SHA to use as the base ref */
|
|
398
|
+
at?: string;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Query parameters accepted by
|
|
403
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}`.
|
|
404
|
+
*
|
|
405
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-raw-path-get}
|
|
406
|
+
*/
|
|
407
|
+
interface RawFileParams {
|
|
408
|
+
/** Branch, tag, or commit SHA to retrieve the file at */
|
|
409
|
+
at?: string;
|
|
410
|
+
}
|
|
411
|
+
|
|
208
412
|
/** Minimal user shape used inside activity records. */
|
|
209
413
|
interface BitbucketActivityUser {
|
|
210
414
|
name: string;
|
|
@@ -287,6 +491,127 @@ interface ActivitiesParams extends PaginationParams {
|
|
|
287
491
|
fromType?: 'COMMENT' | 'ACTIVITY';
|
|
288
492
|
}
|
|
289
493
|
|
|
494
|
+
/** The state of a pull request task. */
|
|
495
|
+
type PullRequestTaskState = 'OPEN' | 'RESOLVED';
|
|
496
|
+
/** Operations the authenticated user is permitted to perform on a task. */
|
|
497
|
+
interface PullRequestTaskPermittedOperations {
|
|
498
|
+
editable: boolean;
|
|
499
|
+
deletable: boolean;
|
|
500
|
+
transitionable: boolean;
|
|
501
|
+
}
|
|
502
|
+
/** The comment anchor to which a task is attached. */
|
|
503
|
+
interface PullRequestTaskAnchor {
|
|
504
|
+
id: number;
|
|
505
|
+
type: {
|
|
506
|
+
id: 'COMMENT';
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Represents a task (review to-do item) on a Bitbucket Data Center pull request.
|
|
511
|
+
*
|
|
512
|
+
* Tasks are created by reviewers on specific comments and can be either `OPEN` or `RESOLVED`.
|
|
513
|
+
*/
|
|
514
|
+
interface BitbucketPullRequestTask {
|
|
515
|
+
id: number;
|
|
516
|
+
createdDate: number;
|
|
517
|
+
author: BitbucketActivityUser;
|
|
518
|
+
text: string;
|
|
519
|
+
state: PullRequestTaskState;
|
|
520
|
+
permittedOperations: PullRequestTaskPermittedOperations;
|
|
521
|
+
/** The comment the task is anchored to */
|
|
522
|
+
anchor: PullRequestTaskAnchor;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Query parameters accepted by
|
|
526
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/tasks`.
|
|
527
|
+
*
|
|
528
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-pull-requests/#api-api-latest-projects-projectkey-repos-repositoryslug-pull-requests-pullrequestid-tasks-get}
|
|
529
|
+
*/
|
|
530
|
+
interface TasksParams extends PaginationParams {
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** The overall result of a Code Insights report. */
|
|
534
|
+
type ReportResult = 'PASS' | 'FAIL';
|
|
535
|
+
/** The data types supported for report data items. */
|
|
536
|
+
type ReportDataType = 'BOOLEAN' | 'DATE' | 'DURATION' | 'LINK' | 'NUMBER' | 'PERCENTAGE' | 'TEXT';
|
|
537
|
+
/** A single data point included in a Code Insights report. */
|
|
538
|
+
interface BitbucketReportData {
|
|
539
|
+
title: string;
|
|
540
|
+
type: ReportDataType;
|
|
541
|
+
value: string | number | boolean | {
|
|
542
|
+
href: string;
|
|
543
|
+
text?: string;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Represents a Code Insights report attached to a pull request in Bitbucket Data Center.
|
|
548
|
+
*
|
|
549
|
+
* Reports are created by external tools (CI, static analysis, coverage) and
|
|
550
|
+
* displayed in the pull request overview.
|
|
551
|
+
*/
|
|
552
|
+
interface BitbucketReport {
|
|
553
|
+
/** Unique key identifying the report */
|
|
554
|
+
key: string;
|
|
555
|
+
title: string;
|
|
556
|
+
details?: string;
|
|
557
|
+
/** Overall result of the report */
|
|
558
|
+
result?: ReportResult;
|
|
559
|
+
/** Name of the tool or service that created the report */
|
|
560
|
+
reporter?: string;
|
|
561
|
+
/** Link to the full external report */
|
|
562
|
+
link?: string;
|
|
563
|
+
/** URL of the logo shown in the Bitbucket UI */
|
|
564
|
+
logoUrl?: string;
|
|
565
|
+
/** Structured data points displayed in the report */
|
|
566
|
+
data?: BitbucketReportData[];
|
|
567
|
+
createdDate: number;
|
|
568
|
+
updatedDate: number;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Query parameters accepted by
|
|
572
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/reports`.
|
|
573
|
+
*
|
|
574
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-code-insights/#api-insights-latest-projects-projectkey-repos-repositoryslug-pull-requests-pullrequestid-reports-get}
|
|
575
|
+
*/
|
|
576
|
+
interface ReportsParams extends PaginationParams {
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Aggregated build counts for a single commit hash.
|
|
581
|
+
*/
|
|
582
|
+
interface BitbucketBuildCount {
|
|
583
|
+
successful: number;
|
|
584
|
+
failed: number;
|
|
585
|
+
inProgress: number;
|
|
586
|
+
cancelled: number;
|
|
587
|
+
unknown: number;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Response from the build-summaries endpoint: a map of commit hash → build counts.
|
|
591
|
+
*
|
|
592
|
+
* Each key is a full commit SHA and the value contains the aggregated count of
|
|
593
|
+
* builds in each state for that commit.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```ts
|
|
597
|
+
* {
|
|
598
|
+
* "abc123def456": { successful: 2, failed: 0, inProgress: 0, cancelled: 0, unknown: 0 },
|
|
599
|
+
* "def456abc123": { successful: 0, failed: 1, inProgress: 1, cancelled: 0, unknown: 0 }
|
|
600
|
+
* }
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
603
|
+
type BitbucketBuildSummaries = Record<string, BitbucketBuildCount>;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Represents a Jira issue linked to a Bitbucket Data Center pull request.
|
|
607
|
+
*/
|
|
608
|
+
interface BitbucketIssue {
|
|
609
|
+
/** The Jira issue key (e.g., `'ABC-123'`) */
|
|
610
|
+
key: string;
|
|
611
|
+
/** The URL to the issue in Jira */
|
|
612
|
+
url: string;
|
|
613
|
+
}
|
|
614
|
+
|
|
290
615
|
/**
|
|
291
616
|
* Represents a Bitbucket pull request resource with chainable async methods.
|
|
292
617
|
*
|
|
@@ -301,12 +626,23 @@ interface ActivitiesParams extends PaginationParams {
|
|
|
301
626
|
* // Get activities
|
|
302
627
|
* const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();
|
|
303
628
|
*
|
|
304
|
-
* //
|
|
305
|
-
* const
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
629
|
+
* // Get tasks
|
|
630
|
+
* const tasks = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).tasks();
|
|
631
|
+
*
|
|
632
|
+
* // Get commits
|
|
633
|
+
* const commits = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).commits();
|
|
634
|
+
*
|
|
635
|
+
* // Get changes
|
|
636
|
+
* const changes = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).changes();
|
|
637
|
+
*
|
|
638
|
+
* // Get reports
|
|
639
|
+
* const reports = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).reports();
|
|
640
|
+
*
|
|
641
|
+
* // Get build summaries
|
|
642
|
+
* const builds = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();
|
|
643
|
+
*
|
|
644
|
+
* // Get linked Jira issues
|
|
645
|
+
* const issues = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).issues();
|
|
310
646
|
* ```
|
|
311
647
|
*/
|
|
312
648
|
declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
@@ -337,7 +673,64 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
337
673
|
* @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`
|
|
338
674
|
* @returns An array of pull request activities, ordered from most recent to oldest
|
|
339
675
|
*/
|
|
340
|
-
activities(params?: ActivitiesParams): Promise<BitbucketPullRequestActivity
|
|
676
|
+
activities(params?: ActivitiesParams): Promise<PagedResponse<BitbucketPullRequestActivity>>;
|
|
677
|
+
/**
|
|
678
|
+
* Fetches the tasks (review to-do items) for this pull request.
|
|
679
|
+
*
|
|
680
|
+
* Tasks are created by reviewers on specific comments and can be `OPEN` or `RESOLVED`.
|
|
681
|
+
*
|
|
682
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/tasks`
|
|
683
|
+
*
|
|
684
|
+
* @param params - Optional filters: `limit`, `start`
|
|
685
|
+
* @returns An array of pull request tasks
|
|
686
|
+
*/
|
|
687
|
+
tasks(params?: TasksParams): Promise<PagedResponse<BitbucketPullRequestTask>>;
|
|
688
|
+
/**
|
|
689
|
+
* Fetches the commits included in this pull request.
|
|
690
|
+
*
|
|
691
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/commits`
|
|
692
|
+
*
|
|
693
|
+
* @param params - Optional pagination: `limit`, `start`
|
|
694
|
+
* @returns An array of commits
|
|
695
|
+
*/
|
|
696
|
+
commits(params?: PaginationParams): Promise<PagedResponse<BitbucketCommit>>;
|
|
697
|
+
/**
|
|
698
|
+
* Fetches the file changes included in this pull request.
|
|
699
|
+
*
|
|
700
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/changes`
|
|
701
|
+
*
|
|
702
|
+
* @param params - Optional filters: `limit`, `start`, `withComments`
|
|
703
|
+
* @returns An array of file changes
|
|
704
|
+
*/
|
|
705
|
+
changes(params?: ChangesParams): Promise<PagedResponse<BitbucketChange>>;
|
|
706
|
+
/**
|
|
707
|
+
* Fetches the Code Insights reports for this pull request.
|
|
708
|
+
*
|
|
709
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/reports`
|
|
710
|
+
*
|
|
711
|
+
* @param params - Optional pagination: `limit`, `start`
|
|
712
|
+
* @returns An array of Code Insights reports
|
|
713
|
+
*/
|
|
714
|
+
reports(params?: ReportsParams): Promise<PagedResponse<BitbucketReport>>;
|
|
715
|
+
/**
|
|
716
|
+
* Fetches the aggregated build summaries for this pull request.
|
|
717
|
+
*
|
|
718
|
+
* Returns a map of commit hash → build counts per state
|
|
719
|
+
* (`successful`, `failed`, `inProgress`, `cancelled`, `unknown`).
|
|
720
|
+
*
|
|
721
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/build-summaries`
|
|
722
|
+
*
|
|
723
|
+
* @returns A record keyed by commit SHA with aggregated build counts
|
|
724
|
+
*/
|
|
725
|
+
buildSummaries(): Promise<BitbucketBuildSummaries>;
|
|
726
|
+
/**
|
|
727
|
+
* Fetches the Jira issues linked to this pull request.
|
|
728
|
+
*
|
|
729
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/issues`
|
|
730
|
+
*
|
|
731
|
+
* @returns An array of linked Jira issues
|
|
732
|
+
*/
|
|
733
|
+
issues(): Promise<BitbucketIssue[]>;
|
|
341
734
|
}
|
|
342
735
|
|
|
343
736
|
/**
|
|
@@ -363,11 +756,12 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
363
756
|
*/
|
|
364
757
|
declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
365
758
|
private readonly request;
|
|
759
|
+
private readonly requestText;
|
|
366
760
|
private readonly projectKey;
|
|
367
761
|
private readonly repoSlug;
|
|
368
762
|
private readonly basePath;
|
|
369
763
|
/** @internal */
|
|
370
|
-
constructor(request: RequestFn, projectKey: string, repoSlug: string);
|
|
764
|
+
constructor(request: RequestFn, requestText: RequestTextFn, projectKey: string, repoSlug: string);
|
|
371
765
|
/**
|
|
372
766
|
* Allows the resource to be awaited directly, resolving with the repository info.
|
|
373
767
|
* Delegates to {@link RepositoryResource.get}.
|
|
@@ -389,7 +783,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
389
783
|
* @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`
|
|
390
784
|
* @returns An array of pull requests
|
|
391
785
|
*/
|
|
392
|
-
pullRequests(params?: PullRequestsParams): Promise<BitbucketPullRequest
|
|
786
|
+
pullRequests(params?: PullRequestsParams): Promise<PagedResponse<BitbucketPullRequest>>;
|
|
393
787
|
/**
|
|
394
788
|
* Fetches commits for this repository.
|
|
395
789
|
*
|
|
@@ -398,7 +792,51 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
398
792
|
* @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`
|
|
399
793
|
* @returns An array of commits
|
|
400
794
|
*/
|
|
401
|
-
commits(params?: CommitsParams): Promise<BitbucketCommit
|
|
795
|
+
commits(params?: CommitsParams): Promise<PagedResponse<BitbucketCommit>>;
|
|
796
|
+
/**
|
|
797
|
+
* Fetches the files last modified in this repository along with the commit that last touched each.
|
|
798
|
+
*
|
|
799
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/last-modified`
|
|
800
|
+
*
|
|
801
|
+
* @param params - Optional filters: `limit`, `start`, `at`
|
|
802
|
+
* @returns An array of last-modified entries
|
|
803
|
+
*/
|
|
804
|
+
lastModified(params?: LastModifiedParams): Promise<PagedResponse<BitbucketLastModifiedEntry>>;
|
|
805
|
+
/**
|
|
806
|
+
* Fetches the size of this repository.
|
|
807
|
+
*
|
|
808
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/sizes`
|
|
809
|
+
*
|
|
810
|
+
* @returns The repository size object
|
|
811
|
+
*/
|
|
812
|
+
size(): Promise<BitbucketRepositorySize>;
|
|
813
|
+
/**
|
|
814
|
+
* Fetches branches for this repository.
|
|
815
|
+
*
|
|
816
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/branches`
|
|
817
|
+
*
|
|
818
|
+
* @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`
|
|
819
|
+
* @returns An array of branches
|
|
820
|
+
*/
|
|
821
|
+
branches(params?: BranchesParams): Promise<PagedResponse<BitbucketBranch>>;
|
|
822
|
+
/**
|
|
823
|
+
* Fetches the forks of this repository.
|
|
824
|
+
*
|
|
825
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/forks`
|
|
826
|
+
*
|
|
827
|
+
* @param params - Optional pagination: `limit`, `start`
|
|
828
|
+
* @returns A paged response of forked repositories
|
|
829
|
+
*/
|
|
830
|
+
forks(params?: PaginationParams): Promise<PagedResponse<BitbucketRepository>>;
|
|
831
|
+
/**
|
|
832
|
+
* Fetches tags for this repository.
|
|
833
|
+
*
|
|
834
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/tags`
|
|
835
|
+
*
|
|
836
|
+
* @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`
|
|
837
|
+
* @returns A paged response of tags
|
|
838
|
+
*/
|
|
839
|
+
tags(params?: TagsParams): Promise<PagedResponse<BitbucketTag>>;
|
|
402
840
|
/**
|
|
403
841
|
* Returns a {@link PullRequestResource} for a given pull request ID, providing
|
|
404
842
|
* access to pull request data and sub-resources (activities, etc.).
|
|
@@ -415,11 +853,23 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
415
853
|
* const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();
|
|
416
854
|
* ```
|
|
417
855
|
*/
|
|
856
|
+
/**
|
|
857
|
+
* Fetches the raw content of a file in this repository.
|
|
858
|
+
*
|
|
859
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}`
|
|
860
|
+
*
|
|
861
|
+
* @param filePath - Path to the file (e.g., `'src/index.ts'`)
|
|
862
|
+
* @param params - Optional: `at` (branch, tag, or commit SHA)
|
|
863
|
+
* @returns The raw file content as a string
|
|
864
|
+
*/
|
|
865
|
+
raw(filePath: string, params?: RawFileParams): Promise<string>;
|
|
418
866
|
pullRequest(pullRequestId: number): PullRequestResource;
|
|
419
867
|
}
|
|
420
868
|
|
|
421
869
|
/** @internal */
|
|
422
870
|
type RequestFn = <T>(path: string, params?: Record<string, string | number | boolean>) => Promise<T>;
|
|
871
|
+
/** @internal */
|
|
872
|
+
type RequestTextFn = (path: string, params?: Record<string, string | number | boolean>) => Promise<string>;
|
|
423
873
|
/**
|
|
424
874
|
* Represents a Bitbucket project resource with chainable async methods.
|
|
425
875
|
*
|
|
@@ -436,13 +886,17 @@ type RequestFn = <T>(path: string, params?: Record<string, string | number | boo
|
|
|
436
886
|
*
|
|
437
887
|
* // Navigate into a specific repository
|
|
438
888
|
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();
|
|
889
|
+
*
|
|
890
|
+
* // Get users with access to the project
|
|
891
|
+
* const users = await bbClient.project('PROJ').users({ permission: 'PROJECT_WRITE' });
|
|
439
892
|
* ```
|
|
440
893
|
*/
|
|
441
894
|
declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
442
895
|
private readonly request;
|
|
896
|
+
private readonly requestText;
|
|
443
897
|
private readonly key;
|
|
444
898
|
/** @internal */
|
|
445
|
-
constructor(request: RequestFn, key: string);
|
|
899
|
+
constructor(request: RequestFn, requestText: RequestTextFn, key: string);
|
|
446
900
|
/**
|
|
447
901
|
* Allows the resource to be awaited directly, resolving with the project info.
|
|
448
902
|
* Delegates to {@link ProjectResource.get}.
|
|
@@ -464,7 +918,7 @@ declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
|
464
918
|
* @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`
|
|
465
919
|
* @returns An array of repositories
|
|
466
920
|
*/
|
|
467
|
-
repos(params?: ReposParams): Promise<BitbucketRepository
|
|
921
|
+
repos(params?: ReposParams): Promise<PagedResponse<BitbucketRepository>>;
|
|
468
922
|
/**
|
|
469
923
|
* Returns a {@link RepositoryResource} for a given repository slug, providing
|
|
470
924
|
* access to repository-level data and sub-resources (pull requests, commits, etc.).
|
|
@@ -483,14 +937,57 @@ declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
|
483
937
|
* ```
|
|
484
938
|
*/
|
|
485
939
|
repo(repoSlug: string): RepositoryResource;
|
|
940
|
+
/**
|
|
941
|
+
* Fetches users with explicit permissions on this project.
|
|
942
|
+
*
|
|
943
|
+
* `GET /rest/api/latest/projects/{key}/permissions/users`
|
|
944
|
+
*
|
|
945
|
+
* @param params - Optional filters: `limit`, `start`, `filter`, `permission`
|
|
946
|
+
* @returns An array of user–permission pairs
|
|
947
|
+
*/
|
|
948
|
+
users(params?: ProjectUsersParams): Promise<PagedResponse<BitbucketUserPermission>>;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Represents a Bitbucket user resource.
|
|
953
|
+
*
|
|
954
|
+
* Implements `PromiseLike<BitbucketUser>` so it can be awaited directly
|
|
955
|
+
* to fetch user info.
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* ```typescript
|
|
959
|
+
* // Await directly to get user info
|
|
960
|
+
* const user = await bbClient.user('pilmee');
|
|
961
|
+
* ```
|
|
962
|
+
*/
|
|
963
|
+
declare class UserResource implements PromiseLike<BitbucketUser> {
|
|
964
|
+
private readonly request;
|
|
965
|
+
private readonly basePath;
|
|
966
|
+
/** @internal */
|
|
967
|
+
constructor(request: RequestFn, slug: string);
|
|
968
|
+
/**
|
|
969
|
+
* Allows the resource to be awaited directly, resolving with the user info.
|
|
970
|
+
* Delegates to {@link UserResource.get}.
|
|
971
|
+
*/
|
|
972
|
+
then<TResult1 = BitbucketUser, TResult2 = never>(onfulfilled?: ((value: BitbucketUser) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
973
|
+
/**
|
|
974
|
+
* Fetches the user details.
|
|
975
|
+
*
|
|
976
|
+
* `GET /rest/api/latest/users/{slug}`
|
|
977
|
+
*
|
|
978
|
+
* @returns The user object
|
|
979
|
+
*/
|
|
980
|
+
get(): Promise<BitbucketUser>;
|
|
486
981
|
}
|
|
487
982
|
|
|
488
983
|
/**
|
|
489
984
|
* Constructor options for {@link BitbucketClient}.
|
|
490
985
|
*/
|
|
491
986
|
interface BitbucketClientOptions {
|
|
492
|
-
/** The
|
|
987
|
+
/** The host URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`) */
|
|
493
988
|
apiUrl: string;
|
|
989
|
+
/** The API path to prepend to every request (e.g., `'rest/api/latest'`) */
|
|
990
|
+
apiPath: string;
|
|
494
991
|
/** The username to authenticate with */
|
|
495
992
|
user: string;
|
|
496
993
|
/** The personal access token or password to authenticate with */
|
|
@@ -502,8 +999,9 @@ interface BitbucketClientOptions {
|
|
|
502
999
|
* @example
|
|
503
1000
|
* ```typescript
|
|
504
1001
|
* const bbClient = new BitbucketClient({
|
|
505
|
-
* apiUrl: 'https://bitbucket.example.com
|
|
506
|
-
*
|
|
1002
|
+
* apiUrl: 'https://bitbucket.example.com',
|
|
1003
|
+
* apiPath: 'rest/api/latest',
|
|
1004
|
+
* user: 'pilmee',
|
|
507
1005
|
* token: 'my-token',
|
|
508
1006
|
* });
|
|
509
1007
|
*
|
|
@@ -513,15 +1011,18 @@ interface BitbucketClientOptions {
|
|
|
513
1011
|
* const repo = await bbClient.project('PROJ').repo('my-repo');
|
|
514
1012
|
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });
|
|
515
1013
|
* const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });
|
|
1014
|
+
* const users = await bbClient.users({ filter: 'john' });
|
|
1015
|
+
* const user = await bbClient.user('pilmee');
|
|
516
1016
|
* ```
|
|
517
1017
|
*/
|
|
518
1018
|
declare class BitbucketClient {
|
|
519
1019
|
private readonly security;
|
|
1020
|
+
private readonly apiPath;
|
|
520
1021
|
/**
|
|
521
1022
|
* @param options - Connection and authentication options
|
|
522
1023
|
* @throws {TypeError} If `apiUrl` is not a valid URL
|
|
523
1024
|
*/
|
|
524
|
-
constructor({ apiUrl, user, token }: BitbucketClientOptions);
|
|
1025
|
+
constructor({ apiUrl, apiPath, user, token }: BitbucketClientOptions);
|
|
525
1026
|
/**
|
|
526
1027
|
* Performs an authenticated GET request to the Bitbucket REST API.
|
|
527
1028
|
*
|
|
@@ -531,6 +1032,7 @@ declare class BitbucketClient {
|
|
|
531
1032
|
* @internal
|
|
532
1033
|
*/
|
|
533
1034
|
private request;
|
|
1035
|
+
private requestText;
|
|
534
1036
|
/**
|
|
535
1037
|
* Fetches all projects accessible to the authenticated user.
|
|
536
1038
|
*
|
|
@@ -539,7 +1041,7 @@ declare class BitbucketClient {
|
|
|
539
1041
|
* @param params - Optional filters: `limit`, `start`, `name`, `permission`
|
|
540
1042
|
* @returns An array of projects
|
|
541
1043
|
*/
|
|
542
|
-
projects(params?: ProjectsParams): Promise<BitbucketProject
|
|
1044
|
+
projects(params?: ProjectsParams): Promise<PagedResponse<BitbucketProject>>;
|
|
543
1045
|
/**
|
|
544
1046
|
* Returns a {@link ProjectResource} for a given project key, providing access
|
|
545
1047
|
* to project-level data and sub-resources.
|
|
@@ -558,6 +1060,30 @@ declare class BitbucketClient {
|
|
|
558
1060
|
* ```
|
|
559
1061
|
*/
|
|
560
1062
|
project(projectKey: string): ProjectResource;
|
|
1063
|
+
/**
|
|
1064
|
+
* Fetches all users accessible to the authenticated user.
|
|
1065
|
+
*
|
|
1066
|
+
* `GET /rest/api/latest/users`
|
|
1067
|
+
*
|
|
1068
|
+
* @param params - Optional filters: `limit`, `start`, `filter`
|
|
1069
|
+
* @returns An array of users
|
|
1070
|
+
*/
|
|
1071
|
+
users(params?: UsersParams): Promise<PagedResponse<BitbucketUser>>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Returns a {@link UserResource} for a given user slug, providing access
|
|
1074
|
+
* to user data.
|
|
1075
|
+
*
|
|
1076
|
+
* The returned resource can be awaited directly to fetch user info.
|
|
1077
|
+
*
|
|
1078
|
+
* @param slug - The user slug (e.g., `'pilmee'`)
|
|
1079
|
+
* @returns A chainable user resource
|
|
1080
|
+
*
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```typescript
|
|
1083
|
+
* const user = await bbClient.user('pilmee');
|
|
1084
|
+
* ```
|
|
1085
|
+
*/
|
|
1086
|
+
user(slug: string): UserResource;
|
|
561
1087
|
}
|
|
562
1088
|
|
|
563
1089
|
/**
|
|
@@ -609,4 +1135,4 @@ declare class Security {
|
|
|
609
1135
|
getHeaders(): Record<string, string>;
|
|
610
1136
|
}
|
|
611
1137
|
|
|
612
|
-
export { type ActivitiesParams, type BitbucketActivityUser, BitbucketClient, type BitbucketClientOptions, type BitbucketCommit, type BitbucketCommitAuthor, type BitbucketParticipant, type BitbucketProject, type BitbucketPullRequest, type BitbucketPullRequestActivity, type BitbucketPullRequestComment, type BitbucketRef, type BitbucketRepository, type CommitsParams, type PagedResponse, type PaginationParams, ProjectResource, type ProjectsParams, type PullRequestActivityAction, PullRequestResource, type PullRequestsParams, type ReposParams, RepositoryResource, Security };
|
|
1138
|
+
export { type ActivitiesParams, type BitbucketActivityUser, type BitbucketBranch, type BitbucketBuildCount, type BitbucketBuildSummaries, type BitbucketChange, type BitbucketChangePath, BitbucketClient, type BitbucketClientOptions, type BitbucketCommit, type BitbucketCommitAuthor, type BitbucketIssue, type BitbucketLastModifiedEntry, type BitbucketParticipant, type BitbucketProject, type BitbucketPullRequest, type BitbucketPullRequestActivity, type BitbucketPullRequestComment, type BitbucketPullRequestTask, type BitbucketRef, type BitbucketReport, type BitbucketReportData, type BitbucketRepository, type BitbucketRepositorySize, type BitbucketTag, type BitbucketUser, type BitbucketUserPermission, type BranchesParams, type ChangeNodeType, type ChangeType, type ChangesParams, type CommitsParams, type LastModifiedParams, type PagedResponse, type PaginationParams, ProjectResource, type ProjectUsersParams, type ProjectsParams, type PullRequestActivityAction, PullRequestResource, type PullRequestTaskAnchor, type PullRequestTaskPermittedOperations, type PullRequestTaskState, type PullRequestsParams, type RawFileParams, type ReportDataType, type ReportResult, type ReportsParams, type ReposParams, RepositoryResource, Security, type TagsParams, type TasksParams, UserResource, type UsersParams };
|