bitbucket-datacenter-api-client 1.2.0 → 1.4.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/dist/index.d.mts +88 -15
- package/dist/index.d.ts +88 -15
- package/dist/index.js +54 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -28
- 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[];
|
|
@@ -284,6 +285,34 @@ interface BranchesParams extends PaginationParams {
|
|
|
284
285
|
boostMatches?: boolean;
|
|
285
286
|
}
|
|
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
|
+
|
|
287
316
|
/**
|
|
288
317
|
* Size information for a Bitbucket repository.
|
|
289
318
|
*
|
|
@@ -644,7 +673,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
644
673
|
* @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`
|
|
645
674
|
* @returns An array of pull request activities, ordered from most recent to oldest
|
|
646
675
|
*/
|
|
647
|
-
activities(params?: ActivitiesParams): Promise<BitbucketPullRequestActivity
|
|
676
|
+
activities(params?: ActivitiesParams): Promise<PagedResponse<BitbucketPullRequestActivity>>;
|
|
648
677
|
/**
|
|
649
678
|
* Fetches the tasks (review to-do items) for this pull request.
|
|
650
679
|
*
|
|
@@ -655,7 +684,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
655
684
|
* @param params - Optional filters: `limit`, `start`
|
|
656
685
|
* @returns An array of pull request tasks
|
|
657
686
|
*/
|
|
658
|
-
tasks(params?: TasksParams): Promise<BitbucketPullRequestTask
|
|
687
|
+
tasks(params?: TasksParams): Promise<PagedResponse<BitbucketPullRequestTask>>;
|
|
659
688
|
/**
|
|
660
689
|
* Fetches the commits included in this pull request.
|
|
661
690
|
*
|
|
@@ -664,7 +693,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
664
693
|
* @param params - Optional pagination: `limit`, `start`
|
|
665
694
|
* @returns An array of commits
|
|
666
695
|
*/
|
|
667
|
-
commits(params?: PaginationParams): Promise<BitbucketCommit
|
|
696
|
+
commits(params?: PaginationParams): Promise<PagedResponse<BitbucketCommit>>;
|
|
668
697
|
/**
|
|
669
698
|
* Fetches the file changes included in this pull request.
|
|
670
699
|
*
|
|
@@ -673,7 +702,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
673
702
|
* @param params - Optional filters: `limit`, `start`, `withComments`
|
|
674
703
|
* @returns An array of file changes
|
|
675
704
|
*/
|
|
676
|
-
changes(params?: ChangesParams): Promise<BitbucketChange
|
|
705
|
+
changes(params?: ChangesParams): Promise<PagedResponse<BitbucketChange>>;
|
|
677
706
|
/**
|
|
678
707
|
* Fetches the Code Insights reports for this pull request.
|
|
679
708
|
*
|
|
@@ -682,7 +711,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
682
711
|
* @param params - Optional pagination: `limit`, `start`
|
|
683
712
|
* @returns An array of Code Insights reports
|
|
684
713
|
*/
|
|
685
|
-
reports(params?: ReportsParams): Promise<BitbucketReport
|
|
714
|
+
reports(params?: ReportsParams): Promise<PagedResponse<BitbucketReport>>;
|
|
686
715
|
/**
|
|
687
716
|
* Fetches the aggregated build summaries for this pull request.
|
|
688
717
|
*
|
|
@@ -754,7 +783,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
754
783
|
* @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`
|
|
755
784
|
* @returns An array of pull requests
|
|
756
785
|
*/
|
|
757
|
-
pullRequests(params?: PullRequestsParams): Promise<BitbucketPullRequest
|
|
786
|
+
pullRequests(params?: PullRequestsParams): Promise<PagedResponse<BitbucketPullRequest>>;
|
|
758
787
|
/**
|
|
759
788
|
* Fetches commits for this repository.
|
|
760
789
|
*
|
|
@@ -763,7 +792,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
763
792
|
* @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`
|
|
764
793
|
* @returns An array of commits
|
|
765
794
|
*/
|
|
766
|
-
commits(params?: CommitsParams): Promise<BitbucketCommit
|
|
795
|
+
commits(params?: CommitsParams): Promise<PagedResponse<BitbucketCommit>>;
|
|
767
796
|
/**
|
|
768
797
|
* Fetches the files last modified in this repository along with the commit that last touched each.
|
|
769
798
|
*
|
|
@@ -772,7 +801,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
772
801
|
* @param params - Optional filters: `limit`, `start`, `at`
|
|
773
802
|
* @returns An array of last-modified entries
|
|
774
803
|
*/
|
|
775
|
-
lastModified(params?: LastModifiedParams): Promise<BitbucketLastModifiedEntry
|
|
804
|
+
lastModified(params?: LastModifiedParams): Promise<PagedResponse<BitbucketLastModifiedEntry>>;
|
|
776
805
|
/**
|
|
777
806
|
* Fetches the size of this repository.
|
|
778
807
|
*
|
|
@@ -789,7 +818,25 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
789
818
|
* @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`
|
|
790
819
|
* @returns An array of branches
|
|
791
820
|
*/
|
|
792
|
-
branches(params?: BranchesParams): Promise<BitbucketBranch
|
|
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>>;
|
|
793
840
|
/**
|
|
794
841
|
* Returns a {@link PullRequestResource} for a given pull request ID, providing
|
|
795
842
|
* access to pull request data and sub-resources (activities, etc.).
|
|
@@ -871,7 +918,7 @@ declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
|
871
918
|
* @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`
|
|
872
919
|
* @returns An array of repositories
|
|
873
920
|
*/
|
|
874
|
-
repos(params?: ReposParams): Promise<BitbucketRepository
|
|
921
|
+
repos(params?: ReposParams): Promise<PagedResponse<BitbucketRepository>>;
|
|
875
922
|
/**
|
|
876
923
|
* Returns a {@link RepositoryResource} for a given repository slug, providing
|
|
877
924
|
* access to repository-level data and sub-resources (pull requests, commits, etc.).
|
|
@@ -898,7 +945,7 @@ declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
|
898
945
|
* @param params - Optional filters: `limit`, `start`, `filter`, `permission`
|
|
899
946
|
* @returns An array of user–permission pairs
|
|
900
947
|
*/
|
|
901
|
-
users(params?: ProjectUsersParams): Promise<BitbucketUserPermission
|
|
948
|
+
users(params?: ProjectUsersParams): Promise<PagedResponse<BitbucketUserPermission>>;
|
|
902
949
|
}
|
|
903
950
|
|
|
904
951
|
/**
|
|
@@ -994,7 +1041,7 @@ declare class BitbucketClient {
|
|
|
994
1041
|
* @param params - Optional filters: `limit`, `start`, `name`, `permission`
|
|
995
1042
|
* @returns An array of projects
|
|
996
1043
|
*/
|
|
997
|
-
projects(params?: ProjectsParams): Promise<BitbucketProject
|
|
1044
|
+
projects(params?: ProjectsParams): Promise<PagedResponse<BitbucketProject>>;
|
|
998
1045
|
/**
|
|
999
1046
|
* Returns a {@link ProjectResource} for a given project key, providing access
|
|
1000
1047
|
* to project-level data and sub-resources.
|
|
@@ -1021,7 +1068,7 @@ declare class BitbucketClient {
|
|
|
1021
1068
|
* @param params - Optional filters: `limit`, `start`, `filter`
|
|
1022
1069
|
* @returns An array of users
|
|
1023
1070
|
*/
|
|
1024
|
-
users(params?: UsersParams): Promise<BitbucketUser
|
|
1071
|
+
users(params?: UsersParams): Promise<PagedResponse<BitbucketUser>>;
|
|
1025
1072
|
/**
|
|
1026
1073
|
* Returns a {@link UserResource} for a given user slug, providing access
|
|
1027
1074
|
* to user data.
|
|
@@ -1039,6 +1086,32 @@ declare class BitbucketClient {
|
|
|
1039
1086
|
user(slug: string): UserResource;
|
|
1040
1087
|
}
|
|
1041
1088
|
|
|
1089
|
+
/**
|
|
1090
|
+
* Thrown when the Bitbucket Data Center API returns a non-2xx response.
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```typescript
|
|
1094
|
+
* import { BitbucketApiError } from 'bitbucket-datacenter-api-client';
|
|
1095
|
+
*
|
|
1096
|
+
* try {
|
|
1097
|
+
* await bb.project('NONEXISTENT');
|
|
1098
|
+
* } catch (err) {
|
|
1099
|
+
* if (err instanceof BitbucketApiError) {
|
|
1100
|
+
* console.log(err.status); // 404
|
|
1101
|
+
* console.log(err.statusText); // 'Not Found'
|
|
1102
|
+
* console.log(err.message); // 'Bitbucket API error: 404 Not Found'
|
|
1103
|
+
* }
|
|
1104
|
+
* }
|
|
1105
|
+
* ```
|
|
1106
|
+
*/
|
|
1107
|
+
declare class BitbucketApiError extends Error {
|
|
1108
|
+
/** HTTP status code (e.g. `404`, `401`, `403`) */
|
|
1109
|
+
readonly status: number;
|
|
1110
|
+
/** HTTP status text (e.g. `'Not Found'`, `'Unauthorized'`) */
|
|
1111
|
+
readonly statusText: string;
|
|
1112
|
+
constructor(status: number, statusText: string);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1042
1115
|
/**
|
|
1043
1116
|
* Handles Basic Authentication for Bitbucket Data Center REST API requests.
|
|
1044
1117
|
*
|
|
@@ -1088,4 +1161,4 @@ declare class Security {
|
|
|
1088
1161
|
getHeaders(): Record<string, string>;
|
|
1089
1162
|
}
|
|
1090
1163
|
|
|
1091
|
-
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 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 TasksParams, UserResource, type UsersParams };
|
|
1164
|
+
export { type ActivitiesParams, type BitbucketActivityUser, BitbucketApiError, 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 };
|
package/dist/index.d.ts
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[];
|
|
@@ -284,6 +285,34 @@ interface BranchesParams extends PaginationParams {
|
|
|
284
285
|
boostMatches?: boolean;
|
|
285
286
|
}
|
|
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
|
+
|
|
287
316
|
/**
|
|
288
317
|
* Size information for a Bitbucket repository.
|
|
289
318
|
*
|
|
@@ -644,7 +673,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
644
673
|
* @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`
|
|
645
674
|
* @returns An array of pull request activities, ordered from most recent to oldest
|
|
646
675
|
*/
|
|
647
|
-
activities(params?: ActivitiesParams): Promise<BitbucketPullRequestActivity
|
|
676
|
+
activities(params?: ActivitiesParams): Promise<PagedResponse<BitbucketPullRequestActivity>>;
|
|
648
677
|
/**
|
|
649
678
|
* Fetches the tasks (review to-do items) for this pull request.
|
|
650
679
|
*
|
|
@@ -655,7 +684,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
655
684
|
* @param params - Optional filters: `limit`, `start`
|
|
656
685
|
* @returns An array of pull request tasks
|
|
657
686
|
*/
|
|
658
|
-
tasks(params?: TasksParams): Promise<BitbucketPullRequestTask
|
|
687
|
+
tasks(params?: TasksParams): Promise<PagedResponse<BitbucketPullRequestTask>>;
|
|
659
688
|
/**
|
|
660
689
|
* Fetches the commits included in this pull request.
|
|
661
690
|
*
|
|
@@ -664,7 +693,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
664
693
|
* @param params - Optional pagination: `limit`, `start`
|
|
665
694
|
* @returns An array of commits
|
|
666
695
|
*/
|
|
667
|
-
commits(params?: PaginationParams): Promise<BitbucketCommit
|
|
696
|
+
commits(params?: PaginationParams): Promise<PagedResponse<BitbucketCommit>>;
|
|
668
697
|
/**
|
|
669
698
|
* Fetches the file changes included in this pull request.
|
|
670
699
|
*
|
|
@@ -673,7 +702,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
673
702
|
* @param params - Optional filters: `limit`, `start`, `withComments`
|
|
674
703
|
* @returns An array of file changes
|
|
675
704
|
*/
|
|
676
|
-
changes(params?: ChangesParams): Promise<BitbucketChange
|
|
705
|
+
changes(params?: ChangesParams): Promise<PagedResponse<BitbucketChange>>;
|
|
677
706
|
/**
|
|
678
707
|
* Fetches the Code Insights reports for this pull request.
|
|
679
708
|
*
|
|
@@ -682,7 +711,7 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
|
|
|
682
711
|
* @param params - Optional pagination: `limit`, `start`
|
|
683
712
|
* @returns An array of Code Insights reports
|
|
684
713
|
*/
|
|
685
|
-
reports(params?: ReportsParams): Promise<BitbucketReport
|
|
714
|
+
reports(params?: ReportsParams): Promise<PagedResponse<BitbucketReport>>;
|
|
686
715
|
/**
|
|
687
716
|
* Fetches the aggregated build summaries for this pull request.
|
|
688
717
|
*
|
|
@@ -754,7 +783,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
754
783
|
* @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`
|
|
755
784
|
* @returns An array of pull requests
|
|
756
785
|
*/
|
|
757
|
-
pullRequests(params?: PullRequestsParams): Promise<BitbucketPullRequest
|
|
786
|
+
pullRequests(params?: PullRequestsParams): Promise<PagedResponse<BitbucketPullRequest>>;
|
|
758
787
|
/**
|
|
759
788
|
* Fetches commits for this repository.
|
|
760
789
|
*
|
|
@@ -763,7 +792,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
763
792
|
* @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`
|
|
764
793
|
* @returns An array of commits
|
|
765
794
|
*/
|
|
766
|
-
commits(params?: CommitsParams): Promise<BitbucketCommit
|
|
795
|
+
commits(params?: CommitsParams): Promise<PagedResponse<BitbucketCommit>>;
|
|
767
796
|
/**
|
|
768
797
|
* Fetches the files last modified in this repository along with the commit that last touched each.
|
|
769
798
|
*
|
|
@@ -772,7 +801,7 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
772
801
|
* @param params - Optional filters: `limit`, `start`, `at`
|
|
773
802
|
* @returns An array of last-modified entries
|
|
774
803
|
*/
|
|
775
|
-
lastModified(params?: LastModifiedParams): Promise<BitbucketLastModifiedEntry
|
|
804
|
+
lastModified(params?: LastModifiedParams): Promise<PagedResponse<BitbucketLastModifiedEntry>>;
|
|
776
805
|
/**
|
|
777
806
|
* Fetches the size of this repository.
|
|
778
807
|
*
|
|
@@ -789,7 +818,25 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
|
789
818
|
* @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`
|
|
790
819
|
* @returns An array of branches
|
|
791
820
|
*/
|
|
792
|
-
branches(params?: BranchesParams): Promise<BitbucketBranch
|
|
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>>;
|
|
793
840
|
/**
|
|
794
841
|
* Returns a {@link PullRequestResource} for a given pull request ID, providing
|
|
795
842
|
* access to pull request data and sub-resources (activities, etc.).
|
|
@@ -871,7 +918,7 @@ declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
|
871
918
|
* @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`
|
|
872
919
|
* @returns An array of repositories
|
|
873
920
|
*/
|
|
874
|
-
repos(params?: ReposParams): Promise<BitbucketRepository
|
|
921
|
+
repos(params?: ReposParams): Promise<PagedResponse<BitbucketRepository>>;
|
|
875
922
|
/**
|
|
876
923
|
* Returns a {@link RepositoryResource} for a given repository slug, providing
|
|
877
924
|
* access to repository-level data and sub-resources (pull requests, commits, etc.).
|
|
@@ -898,7 +945,7 @@ declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
|
898
945
|
* @param params - Optional filters: `limit`, `start`, `filter`, `permission`
|
|
899
946
|
* @returns An array of user–permission pairs
|
|
900
947
|
*/
|
|
901
|
-
users(params?: ProjectUsersParams): Promise<BitbucketUserPermission
|
|
948
|
+
users(params?: ProjectUsersParams): Promise<PagedResponse<BitbucketUserPermission>>;
|
|
902
949
|
}
|
|
903
950
|
|
|
904
951
|
/**
|
|
@@ -994,7 +1041,7 @@ declare class BitbucketClient {
|
|
|
994
1041
|
* @param params - Optional filters: `limit`, `start`, `name`, `permission`
|
|
995
1042
|
* @returns An array of projects
|
|
996
1043
|
*/
|
|
997
|
-
projects(params?: ProjectsParams): Promise<BitbucketProject
|
|
1044
|
+
projects(params?: ProjectsParams): Promise<PagedResponse<BitbucketProject>>;
|
|
998
1045
|
/**
|
|
999
1046
|
* Returns a {@link ProjectResource} for a given project key, providing access
|
|
1000
1047
|
* to project-level data and sub-resources.
|
|
@@ -1021,7 +1068,7 @@ declare class BitbucketClient {
|
|
|
1021
1068
|
* @param params - Optional filters: `limit`, `start`, `filter`
|
|
1022
1069
|
* @returns An array of users
|
|
1023
1070
|
*/
|
|
1024
|
-
users(params?: UsersParams): Promise<BitbucketUser
|
|
1071
|
+
users(params?: UsersParams): Promise<PagedResponse<BitbucketUser>>;
|
|
1025
1072
|
/**
|
|
1026
1073
|
* Returns a {@link UserResource} for a given user slug, providing access
|
|
1027
1074
|
* to user data.
|
|
@@ -1039,6 +1086,32 @@ declare class BitbucketClient {
|
|
|
1039
1086
|
user(slug: string): UserResource;
|
|
1040
1087
|
}
|
|
1041
1088
|
|
|
1089
|
+
/**
|
|
1090
|
+
* Thrown when the Bitbucket Data Center API returns a non-2xx response.
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```typescript
|
|
1094
|
+
* import { BitbucketApiError } from 'bitbucket-datacenter-api-client';
|
|
1095
|
+
*
|
|
1096
|
+
* try {
|
|
1097
|
+
* await bb.project('NONEXISTENT');
|
|
1098
|
+
* } catch (err) {
|
|
1099
|
+
* if (err instanceof BitbucketApiError) {
|
|
1100
|
+
* console.log(err.status); // 404
|
|
1101
|
+
* console.log(err.statusText); // 'Not Found'
|
|
1102
|
+
* console.log(err.message); // 'Bitbucket API error: 404 Not Found'
|
|
1103
|
+
* }
|
|
1104
|
+
* }
|
|
1105
|
+
* ```
|
|
1106
|
+
*/
|
|
1107
|
+
declare class BitbucketApiError extends Error {
|
|
1108
|
+
/** HTTP status code (e.g. `404`, `401`, `403`) */
|
|
1109
|
+
readonly status: number;
|
|
1110
|
+
/** HTTP status text (e.g. `'Not Found'`, `'Unauthorized'`) */
|
|
1111
|
+
readonly statusText: string;
|
|
1112
|
+
constructor(status: number, statusText: string);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1042
1115
|
/**
|
|
1043
1116
|
* Handles Basic Authentication for Bitbucket Data Center REST API requests.
|
|
1044
1117
|
*
|
|
@@ -1088,4 +1161,4 @@ declare class Security {
|
|
|
1088
1161
|
getHeaders(): Record<string, string>;
|
|
1089
1162
|
}
|
|
1090
1163
|
|
|
1091
|
-
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 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 TasksParams, UserResource, type UsersParams };
|
|
1164
|
+
export { type ActivitiesParams, type BitbucketActivityUser, BitbucketApiError, 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 };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
BitbucketApiError: () => BitbucketApiError,
|
|
23
24
|
BitbucketClient: () => BitbucketClient,
|
|
24
25
|
ProjectResource: () => ProjectResource,
|
|
25
26
|
PullRequestResource: () => PullRequestResource,
|
|
@@ -119,11 +120,10 @@ var PullRequestResource = class {
|
|
|
119
120
|
* @returns An array of pull request activities, ordered from most recent to oldest
|
|
120
121
|
*/
|
|
121
122
|
async activities(params) {
|
|
122
|
-
|
|
123
|
+
return this.request(
|
|
123
124
|
`${this.basePath}/activities`,
|
|
124
125
|
params
|
|
125
126
|
);
|
|
126
|
-
return data.values;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Fetches the tasks (review to-do items) for this pull request.
|
|
@@ -136,11 +136,10 @@ var PullRequestResource = class {
|
|
|
136
136
|
* @returns An array of pull request tasks
|
|
137
137
|
*/
|
|
138
138
|
async tasks(params) {
|
|
139
|
-
|
|
139
|
+
return this.request(
|
|
140
140
|
`${this.basePath}/tasks`,
|
|
141
141
|
params
|
|
142
142
|
);
|
|
143
|
-
return data.values;
|
|
144
143
|
}
|
|
145
144
|
/**
|
|
146
145
|
* Fetches the commits included in this pull request.
|
|
@@ -151,11 +150,10 @@ var PullRequestResource = class {
|
|
|
151
150
|
* @returns An array of commits
|
|
152
151
|
*/
|
|
153
152
|
async commits(params) {
|
|
154
|
-
|
|
153
|
+
return this.request(
|
|
155
154
|
`${this.basePath}/commits`,
|
|
156
155
|
params
|
|
157
156
|
);
|
|
158
|
-
return data.values;
|
|
159
157
|
}
|
|
160
158
|
/**
|
|
161
159
|
* Fetches the file changes included in this pull request.
|
|
@@ -166,11 +164,10 @@ var PullRequestResource = class {
|
|
|
166
164
|
* @returns An array of file changes
|
|
167
165
|
*/
|
|
168
166
|
async changes(params) {
|
|
169
|
-
|
|
167
|
+
return this.request(
|
|
170
168
|
`${this.basePath}/changes`,
|
|
171
169
|
params
|
|
172
170
|
);
|
|
173
|
-
return data.values;
|
|
174
171
|
}
|
|
175
172
|
/**
|
|
176
173
|
* Fetches the Code Insights reports for this pull request.
|
|
@@ -181,11 +178,10 @@ var PullRequestResource = class {
|
|
|
181
178
|
* @returns An array of Code Insights reports
|
|
182
179
|
*/
|
|
183
180
|
async reports(params) {
|
|
184
|
-
|
|
181
|
+
return this.request(
|
|
185
182
|
`${this.basePath}/reports`,
|
|
186
183
|
params
|
|
187
184
|
);
|
|
188
|
-
return data.values;
|
|
189
185
|
}
|
|
190
186
|
/**
|
|
191
187
|
* Fetches the aggregated build summaries for this pull request.
|
|
@@ -248,11 +244,10 @@ var RepositoryResource = class {
|
|
|
248
244
|
* @returns An array of pull requests
|
|
249
245
|
*/
|
|
250
246
|
async pullRequests(params) {
|
|
251
|
-
|
|
247
|
+
return this.request(
|
|
252
248
|
`${this.basePath}/pull-requests`,
|
|
253
249
|
params
|
|
254
250
|
);
|
|
255
|
-
return data.values;
|
|
256
251
|
}
|
|
257
252
|
/**
|
|
258
253
|
* Fetches commits for this repository.
|
|
@@ -263,11 +258,10 @@ var RepositoryResource = class {
|
|
|
263
258
|
* @returns An array of commits
|
|
264
259
|
*/
|
|
265
260
|
async commits(params) {
|
|
266
|
-
|
|
261
|
+
return this.request(
|
|
267
262
|
`${this.basePath}/commits`,
|
|
268
263
|
params
|
|
269
264
|
);
|
|
270
|
-
return data.values;
|
|
271
265
|
}
|
|
272
266
|
/**
|
|
273
267
|
* Fetches the files last modified in this repository along with the commit that last touched each.
|
|
@@ -278,11 +272,10 @@ var RepositoryResource = class {
|
|
|
278
272
|
* @returns An array of last-modified entries
|
|
279
273
|
*/
|
|
280
274
|
async lastModified(params) {
|
|
281
|
-
|
|
275
|
+
return this.request(
|
|
282
276
|
`${this.basePath}/last-modified`,
|
|
283
277
|
params
|
|
284
278
|
);
|
|
285
|
-
return data.values;
|
|
286
279
|
}
|
|
287
280
|
/**
|
|
288
281
|
* Fetches the size of this repository.
|
|
@@ -303,11 +296,38 @@ var RepositoryResource = class {
|
|
|
303
296
|
* @returns An array of branches
|
|
304
297
|
*/
|
|
305
298
|
async branches(params) {
|
|
306
|
-
|
|
299
|
+
return this.request(
|
|
307
300
|
`${this.basePath}/branches`,
|
|
308
301
|
params
|
|
309
302
|
);
|
|
310
|
-
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Fetches the forks of this repository.
|
|
306
|
+
*
|
|
307
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/forks`
|
|
308
|
+
*
|
|
309
|
+
* @param params - Optional pagination: `limit`, `start`
|
|
310
|
+
* @returns A paged response of forked repositories
|
|
311
|
+
*/
|
|
312
|
+
async forks(params) {
|
|
313
|
+
return this.request(
|
|
314
|
+
`${this.basePath}/forks`,
|
|
315
|
+
params
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Fetches tags for this repository.
|
|
320
|
+
*
|
|
321
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/tags`
|
|
322
|
+
*
|
|
323
|
+
* @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`
|
|
324
|
+
* @returns A paged response of tags
|
|
325
|
+
*/
|
|
326
|
+
async tags(params) {
|
|
327
|
+
return this.request(
|
|
328
|
+
`${this.basePath}/tags`,
|
|
329
|
+
params
|
|
330
|
+
);
|
|
311
331
|
}
|
|
312
332
|
/**
|
|
313
333
|
* Returns a {@link PullRequestResource} for a given pull request ID, providing
|
|
@@ -379,11 +399,10 @@ var ProjectResource = class {
|
|
|
379
399
|
* @returns An array of repositories
|
|
380
400
|
*/
|
|
381
401
|
async repos(params) {
|
|
382
|
-
|
|
402
|
+
return this.request(
|
|
383
403
|
`/projects/${this.key}/repos`,
|
|
384
404
|
params
|
|
385
405
|
);
|
|
386
|
-
return data.values;
|
|
387
406
|
}
|
|
388
407
|
/**
|
|
389
408
|
* Returns a {@link RepositoryResource} for a given repository slug, providing
|
|
@@ -414,11 +433,20 @@ var ProjectResource = class {
|
|
|
414
433
|
* @returns An array of user–permission pairs
|
|
415
434
|
*/
|
|
416
435
|
async users(params) {
|
|
417
|
-
|
|
436
|
+
return this.request(
|
|
418
437
|
`/projects/${this.key}/permissions/users`,
|
|
419
438
|
params
|
|
420
439
|
);
|
|
421
|
-
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// src/errors/BitbucketApiError.ts
|
|
444
|
+
var BitbucketApiError = class extends Error {
|
|
445
|
+
constructor(status, statusText) {
|
|
446
|
+
super(`Bitbucket API error: ${status} ${statusText}`);
|
|
447
|
+
this.name = "BitbucketApiError";
|
|
448
|
+
this.status = status;
|
|
449
|
+
this.statusText = statusText;
|
|
422
450
|
}
|
|
423
451
|
};
|
|
424
452
|
|
|
@@ -471,7 +499,7 @@ var BitbucketClient = class {
|
|
|
471
499
|
const url = buildUrl(base, params);
|
|
472
500
|
const response = await fetch(url, { headers: this.security.getHeaders() });
|
|
473
501
|
if (!response.ok) {
|
|
474
|
-
throw new
|
|
502
|
+
throw new BitbucketApiError(response.status, response.statusText);
|
|
475
503
|
}
|
|
476
504
|
return response.json();
|
|
477
505
|
}
|
|
@@ -480,7 +508,7 @@ var BitbucketClient = class {
|
|
|
480
508
|
const url = buildUrl(base, params);
|
|
481
509
|
const response = await fetch(url, { headers: this.security.getHeaders() });
|
|
482
510
|
if (!response.ok) {
|
|
483
|
-
throw new
|
|
511
|
+
throw new BitbucketApiError(response.status, response.statusText);
|
|
484
512
|
}
|
|
485
513
|
return response.text();
|
|
486
514
|
}
|
|
@@ -493,11 +521,10 @@ var BitbucketClient = class {
|
|
|
493
521
|
* @returns An array of projects
|
|
494
522
|
*/
|
|
495
523
|
async projects(params) {
|
|
496
|
-
|
|
524
|
+
return this.request(
|
|
497
525
|
"/projects",
|
|
498
526
|
params
|
|
499
527
|
);
|
|
500
|
-
return data.values;
|
|
501
528
|
}
|
|
502
529
|
/**
|
|
503
530
|
* Returns a {@link ProjectResource} for a given project key, providing access
|
|
@@ -530,11 +557,10 @@ var BitbucketClient = class {
|
|
|
530
557
|
* @returns An array of users
|
|
531
558
|
*/
|
|
532
559
|
async users(params) {
|
|
533
|
-
|
|
560
|
+
return this.request(
|
|
534
561
|
"/users",
|
|
535
562
|
params
|
|
536
563
|
);
|
|
537
|
-
return data.values;
|
|
538
564
|
}
|
|
539
565
|
/**
|
|
540
566
|
* Returns a {@link UserResource} for a given user slug, providing access
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/security/Security.ts","../src/resources/PullRequestResource.ts","../src/resources/RepositoryResource.ts","../src/resources/ProjectResource.ts","../src/resources/UserResource.ts","../src/BitbucketClient.ts"],"sourcesContent":["export { BitbucketClient } from './BitbucketClient';\nexport type { BitbucketClientOptions } from './BitbucketClient';\nexport { Security } from './security/Security';\nexport { ProjectResource } from './resources/ProjectResource';\nexport { RepositoryResource } from './resources/RepositoryResource';\nexport { PullRequestResource } from './resources/PullRequestResource';\nexport { UserResource } from './resources/UserResource';\nexport type { BitbucketProject, ProjectsParams } from './domain/Project';\nexport type { BitbucketRepository, ReposParams } from './domain/Repository';\nexport type { BitbucketPullRequest, BitbucketParticipant, BitbucketRef, PullRequestsParams } from './domain/PullRequest';\nexport type { BitbucketPullRequestActivity, BitbucketPullRequestComment, BitbucketActivityUser, PullRequestActivityAction, ActivitiesParams } from './domain/PullRequestActivity';\nexport type { BitbucketPullRequestTask, PullRequestTaskState, PullRequestTaskPermittedOperations, PullRequestTaskAnchor, TasksParams } from './domain/PullRequestTask';\nexport type { BitbucketChange, BitbucketChangePath, ChangeType, ChangeNodeType, ChangesParams } from './domain/Change';\nexport type { BitbucketReport, BitbucketReportData, ReportResult, ReportDataType, ReportsParams } from './domain/Report';\nexport type { BitbucketBuildSummaries, BitbucketBuildCount } from './domain/BuildSummary';\nexport type { BitbucketIssue } from './domain/Issue';\nexport type { BitbucketUser, BitbucketUserPermission, UsersParams, ProjectUsersParams } from './domain/User';\nexport type { BitbucketCommit, BitbucketCommitAuthor, CommitsParams } from './domain/Commit';\nexport type { BitbucketBranch, BranchesParams } from './domain/Branch';\nexport type { BitbucketRepositorySize } from './domain/RepositorySize';\nexport type { BitbucketLastModifiedEntry, LastModifiedParams } from './domain/LastModified';\nexport type { RawFileParams } from './domain/RawFile';\nexport type { PaginationParams, PagedResponse } from './domain/Pagination';\n","/**\n * Encodes a string to Base64 in a way that works in both Node.js and browsers.\n * @internal\n */\nfunction toBase64(value: string): string {\n if (typeof btoa !== 'undefined') {\n return btoa(value);\n }\n return Buffer.from(value).toString('base64');\n}\n\n/**\n * Handles Basic Authentication for Bitbucket Data Center REST API requests.\n *\n * @example\n * ```typescript\n * const security = new Security(\n * 'https://bitbucket.example.com',\n * 'my-user',\n * 'my-token'\n * );\n *\n * const headers = security.getHeaders();\n * // { Authorization: 'Basic <base64>', 'Content-Type': 'application/json', Accept: 'application/json' }\n * ```\n */\nexport class Security {\n private readonly apiUrl: string;\n private readonly authorizationHeader: string;\n\n /**\n * Creates a new Security instance with Basic Authentication credentials.\n *\n * @param apiUrl - The base URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`).\n * Must be a valid URL; throws if it cannot be parsed.\n * @param user - The username to authenticate with\n * @param token - The personal access token or password to authenticate with\n *\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor(apiUrl: string, user: string, token: string) {\n if (!URL.canParse(apiUrl)) {\n throw new TypeError(`Invalid apiUrl: \"${apiUrl}\" is not a valid URL`);\n }\n this.apiUrl = apiUrl.replace(/\\/$/, '');\n this.authorizationHeader = `Basic ${toBase64(`${user}:${token}`)}`;\n }\n\n /**\n * Returns the base URL of the Bitbucket Data Center instance, without a trailing slash.\n *\n * @returns The API base URL\n */\n getApiUrl(): string {\n return this.apiUrl;\n }\n\n /**\n * Returns the value of the `Authorization` header for Basic Authentication.\n *\n * @returns The Authorization header value in the format `Basic <base64-encoded-credentials>`\n */\n getAuthorizationHeader(): string {\n return this.authorizationHeader;\n }\n\n /**\n * Returns the full set of HTTP headers required for authenticated API requests.\n *\n * @returns An object containing `Authorization`, `Content-Type`, and `Accept` headers\n */\n getHeaders(): Record<string, string> {\n return {\n Authorization: this.authorizationHeader,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n","import type { BitbucketPullRequest } from '../domain/PullRequest';\nimport type { BitbucketPullRequestActivity, ActivitiesParams } from '../domain/PullRequestActivity';\nimport type { BitbucketPullRequestTask, TasksParams } from '../domain/PullRequestTask';\nimport type { BitbucketCommit } from '../domain/Commit';\nimport type { BitbucketChange, ChangesParams } from '../domain/Change';\nimport type { BitbucketReport, ReportsParams } from '../domain/Report';\nimport type { BitbucketBuildSummaries } from '../domain/BuildSummary';\nimport type { BitbucketIssue } from '../domain/Issue';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket pull request resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketPullRequest>` so it can be awaited directly\n * to fetch the pull request info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get pull request info\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n *\n * // Get activities\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get tasks\n * const tasks = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).tasks();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).commits();\n *\n * // Get changes\n * const changes = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).changes();\n *\n * // Get reports\n * const reports = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).reports();\n *\n * // Get build summaries\n * const builds = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();\n *\n * // Get linked Jira issues\n * const issues = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).issues();\n * ```\n */\nexport class PullRequestResource implements PromiseLike<BitbucketPullRequest> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n projectKey: string,\n repoSlug: string,\n pullRequestId: number,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}/pull-requests/${pullRequestId}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the pull request info.\n * Delegates to {@link PullRequestResource.get}.\n */\n then<TResult1 = BitbucketPullRequest, TResult2 = never>(\n onfulfilled?: ((value: BitbucketPullRequest) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the pull request details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}`\n *\n * @returns The pull request object\n */\n async get(): Promise<BitbucketPullRequest> {\n return this.request<BitbucketPullRequest>(this.basePath);\n }\n\n /**\n * Fetches the activity feed for this pull request.\n *\n * Activities include comments, approvals, reviews, rescopes, merges, and declines.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/activities`\n *\n * @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`\n * @returns An array of pull request activities, ordered from most recent to oldest\n */\n async activities(params?: ActivitiesParams): Promise<BitbucketPullRequestActivity[]> {\n const data = await this.request<PagedResponse<BitbucketPullRequestActivity>>(\n `${this.basePath}/activities`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the tasks (review to-do items) for this pull request.\n *\n * Tasks are created by reviewers on specific comments and can be `OPEN` or `RESOLVED`.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/tasks`\n *\n * @param params - Optional filters: `limit`, `start`\n * @returns An array of pull request tasks\n */\n async tasks(params?: TasksParams): Promise<BitbucketPullRequestTask[]> {\n const data = await this.request<PagedResponse<BitbucketPullRequestTask>>(\n `${this.basePath}/tasks`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the commits included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/commits`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of commits\n */\n async commits(params?: PaginationParams): Promise<BitbucketCommit[]> {\n const data = await this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the file changes included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/changes`\n *\n * @param params - Optional filters: `limit`, `start`, `withComments`\n * @returns An array of file changes\n */\n async changes(params?: ChangesParams): Promise<BitbucketChange[]> {\n const data = await this.request<PagedResponse<BitbucketChange>>(\n `${this.basePath}/changes`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the Code Insights reports for this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/reports`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of Code Insights reports\n */\n async reports(params?: ReportsParams): Promise<BitbucketReport[]> {\n const data = await this.request<PagedResponse<BitbucketReport>>(\n `${this.basePath}/reports`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the aggregated build summaries for this pull request.\n *\n * Returns a map of commit hash → build counts per state\n * (`successful`, `failed`, `inProgress`, `cancelled`, `unknown`).\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/build-summaries`\n *\n * @returns A record keyed by commit SHA with aggregated build counts\n */\n async buildSummaries(): Promise<BitbucketBuildSummaries> {\n return this.request<BitbucketBuildSummaries>(`${this.basePath}/build-summaries`);\n }\n\n /**\n * Fetches the Jira issues linked to this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/issues`\n *\n * @returns An array of linked Jira issues\n */\n async issues(): Promise<BitbucketIssue[]> {\n return this.request<BitbucketIssue[]>(`${this.basePath}/issues`);\n }\n}\n","import type { BitbucketRepository } from '../domain/Repository';\nimport type { BitbucketPullRequest, PullRequestsParams } from '../domain/PullRequest';\nimport type { BitbucketCommit, CommitsParams } from '../domain/Commit';\nimport type { BitbucketBranch, BranchesParams } from '../domain/Branch';\nimport type { BitbucketRepositorySize } from '../domain/RepositorySize';\nimport type { BitbucketLastModifiedEntry, LastModifiedParams } from '../domain/LastModified';\nimport type { RawFileParams } from '../domain/RawFile';\nimport type { PagedResponse } from '../domain/Pagination';\nimport type { RequestFn, RequestTextFn } from './ProjectResource';\nimport { PullRequestResource } from './PullRequestResource';\n\n/**\n * Represents a Bitbucket repository resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketRepository>` so it can be awaited directly\n * to fetch repository info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get repository info\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n *\n * // Get pull requests\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n *\n * // Navigate into a specific pull request\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\nexport class RepositoryResource implements PromiseLike<BitbucketRepository> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly projectKey: string,\n private readonly repoSlug: string,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the repository info.\n * Delegates to {@link RepositoryResource.get}.\n */\n then<TResult1 = BitbucketRepository, TResult2 = never>(\n onfulfilled?: ((value: BitbucketRepository) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the repository details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}`\n *\n * @returns The repository object\n */\n async get(): Promise<BitbucketRepository> {\n return this.request<BitbucketRepository>(this.basePath);\n }\n\n /**\n * Fetches pull requests for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests`\n *\n * @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`\n * @returns An array of pull requests\n */\n async pullRequests(params?: PullRequestsParams): Promise<BitbucketPullRequest[]> {\n const data = await this.request<PagedResponse<BitbucketPullRequest>>(\n `${this.basePath}/pull-requests`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches commits for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/commits`\n *\n * @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`\n * @returns An array of commits\n */\n async commits(params?: CommitsParams): Promise<BitbucketCommit[]> {\n const data = await this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the files last modified in this repository along with the commit that last touched each.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/last-modified`\n *\n * @param params - Optional filters: `limit`, `start`, `at`\n * @returns An array of last-modified entries\n */\n async lastModified(params?: LastModifiedParams): Promise<BitbucketLastModifiedEntry[]> {\n const data = await this.request<PagedResponse<BitbucketLastModifiedEntry>>(\n `${this.basePath}/last-modified`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the size of this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/sizes`\n *\n * @returns The repository size object\n */\n async size(): Promise<BitbucketRepositorySize> {\n return this.request<BitbucketRepositorySize>(`${this.basePath}/sizes`);\n }\n\n /**\n * Fetches branches for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/branches`\n *\n * @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`\n * @returns An array of branches\n */\n async branches(params?: BranchesParams): Promise<BitbucketBranch[]> {\n const data = await this.request<PagedResponse<BitbucketBranch>>(\n `${this.basePath}/branches`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link PullRequestResource} for a given pull request ID, providing\n * access to pull request data and sub-resources (activities, etc.).\n *\n * The returned resource can be awaited directly to fetch pull request info,\n * or chained to access nested resources.\n *\n * @param pullRequestId - The numeric pull request ID\n * @returns A chainable pull request resource\n *\n * @example\n * ```typescript\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n * ```\n */\n /**\n * Fetches the raw content of a file in this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}`\n *\n * @param filePath - Path to the file (e.g., `'src/index.ts'`)\n * @param params - Optional: `at` (branch, tag, or commit SHA)\n * @returns The raw file content as a string\n */\n async raw(filePath: string, params?: RawFileParams): Promise<string> {\n return this.requestText(\n `${this.basePath}/raw/${filePath}`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n pullRequest(pullRequestId: number): PullRequestResource {\n return new PullRequestResource(this.request, this.projectKey, this.repoSlug, pullRequestId);\n }\n}\n","import type { BitbucketProject } from '../domain/Project';\nimport type { BitbucketRepository, ReposParams } from '../domain/Repository';\nimport type { BitbucketUserPermission, ProjectUsersParams } from '../domain/User';\nimport type { PagedResponse } from '../domain/Pagination';\nimport { RepositoryResource } from './RepositoryResource';\n\n/** @internal */\nexport type RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<T>;\n\n/** @internal */\nexport type RequestTextFn = (\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<string>;\n\n/**\n * Represents a Bitbucket project resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketProject>` so it can be awaited directly\n * to fetch the project info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get project info\n * const project = await bbClient.project('PROJ');\n *\n * // Get repositories with filters\n * const repos = await bbClient.project('PROJ').repos({ limit: 50, name: 'api' });\n *\n * // Navigate into a specific repository\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n *\n * // Get users with access to the project\n * const users = await bbClient.project('PROJ').users({ permission: 'PROJECT_WRITE' });\n * ```\n */\nexport class ProjectResource implements PromiseLike<BitbucketProject> {\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly key: string,\n ) {}\n\n /**\n * Allows the resource to be awaited directly, resolving with the project info.\n * Delegates to {@link ProjectResource.get}.\n */\n then<TResult1 = BitbucketProject, TResult2 = never>(\n onfulfilled?: ((value: BitbucketProject) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the project details.\n *\n * `GET /rest/api/latest/projects/{key}`\n *\n * @returns The project object\n */\n async get(): Promise<BitbucketProject> {\n return this.request<BitbucketProject>(`/projects/${this.key}`);\n }\n\n /**\n * Fetches repositories belonging to this project.\n *\n * `GET /rest/api/latest/projects/{key}/repos`\n *\n * @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`\n * @returns An array of repositories\n */\n async repos(params?: ReposParams): Promise<BitbucketRepository[]> {\n const data = await this.request<PagedResponse<BitbucketRepository>>(\n `/projects/${this.key}/repos`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link RepositoryResource} for a given repository slug, providing\n * access to repository-level data and sub-resources (pull requests, commits, etc.).\n *\n * The returned resource can be awaited directly to fetch repository info,\n * or chained to access nested resources.\n *\n * @param repoSlug - The repository slug (e.g., `'my-repo'`)\n * @returns A chainable repository resource\n *\n * @example\n * ```typescript\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\n repo(repoSlug: string): RepositoryResource {\n return new RepositoryResource(this.request, this.requestText, this.key, repoSlug);\n }\n\n /**\n * Fetches users with explicit permissions on this project.\n *\n * `GET /rest/api/latest/projects/{key}/permissions/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`, `permission`\n * @returns An array of user–permission pairs\n */\n async users(params?: ProjectUsersParams): Promise<BitbucketUserPermission[]> {\n const data = await this.request<PagedResponse<BitbucketUserPermission>>(\n `/projects/${this.key}/permissions/users`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n}\n","import type { BitbucketUser } from '../domain/User';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket user resource.\n *\n * Implements `PromiseLike<BitbucketUser>` so it can be awaited directly\n * to fetch user info.\n *\n * @example\n * ```typescript\n * // Await directly to get user info\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class UserResource implements PromiseLike<BitbucketUser> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n slug: string,\n ) {\n this.basePath = `/users/${slug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the user info.\n * Delegates to {@link UserResource.get}.\n */\n then<TResult1 = BitbucketUser, TResult2 = never>(\n onfulfilled?: ((value: BitbucketUser) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the user details.\n *\n * `GET /rest/api/latest/users/{slug}`\n *\n * @returns The user object\n */\n async get(): Promise<BitbucketUser> {\n return this.request<BitbucketUser>(this.basePath);\n }\n}\n","import { Security } from './security/Security';\nimport { ProjectResource, type RequestFn, type RequestTextFn } from './resources/ProjectResource';\nimport { UserResource } from './resources/UserResource';\nimport type { BitbucketProject, ProjectsParams } from './domain/Project';\nimport type { BitbucketUser, UsersParams } from './domain/User';\nimport type { PagedResponse } from './domain/Pagination';\n\n/**\n * Constructor options for {@link BitbucketClient}.\n */\nexport interface BitbucketClientOptions {\n /** The host URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`) */\n apiUrl: string;\n /** The API path to prepend to every request (e.g., `'rest/api/latest'`) */\n apiPath: string;\n /** The username to authenticate with */\n user: string;\n /** The personal access token or password to authenticate with */\n token: string;\n}\n\n/**\n * Main entry point for the Bitbucket Data Center REST API client.\n *\n * @example\n * ```typescript\n * const bbClient = new BitbucketClient({\n * apiUrl: 'https://bitbucket.example.com',\n * apiPath: 'rest/api/latest',\n * user: 'pilmee',\n * token: 'my-token',\n * });\n *\n * const projects = await bbClient.projects({ limit: 50 });\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ name: 'api' });\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * const users = await bbClient.users({ filter: 'john' });\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class BitbucketClient {\n private readonly security: Security;\n private readonly apiPath: string;\n\n /**\n * @param options - Connection and authentication options\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor({ apiUrl, apiPath, user, token }: BitbucketClientOptions) {\n this.security = new Security(apiUrl, user, token);\n this.apiPath = apiPath.replace(/^\\/|\\/$/g, '');\n }\n\n /**\n * Performs an authenticated GET request to the Bitbucket REST API.\n *\n * @param path - API path appended directly to `apiUrl` (e.g., `'/projects'`)\n * @param params - Optional query parameters to append to the URL\n * @throws {Error} If the HTTP response is not OK\n * @internal\n */\n private async request<T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<T> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new Error(`Bitbucket API error: ${response.status} ${response.statusText}`);\n }\n return response.json() as Promise<T>;\n }\n\n private async requestText(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<string> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new Error(`Bitbucket API error: ${response.status} ${response.statusText}`);\n }\n return response.text();\n }\n\n /**\n * Fetches all projects accessible to the authenticated user.\n *\n * `GET /rest/api/latest/projects`\n *\n * @param params - Optional filters: `limit`, `start`, `name`, `permission`\n * @returns An array of projects\n */\n async projects(params?: ProjectsParams): Promise<BitbucketProject[]> {\n const data = await this.request<PagedResponse<BitbucketProject>>(\n '/projects',\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link ProjectResource} for a given project key, providing access\n * to project-level data and sub-resources.\n *\n * The returned resource can be awaited directly to fetch project info,\n * or chained to access nested resources.\n *\n * @param projectKey - The project key (e.g., `'PROJ'`)\n * @returns A chainable project resource\n *\n * @example\n * ```typescript\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ limit: 10 });\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n * ```\n */\n project(projectKey: string): ProjectResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n const requestText: RequestTextFn = (path, params) => this.requestText(path, params);\n return new ProjectResource(request, requestText, projectKey);\n }\n\n /**\n * Fetches all users accessible to the authenticated user.\n *\n * `GET /rest/api/latest/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`\n * @returns An array of users\n */\n async users(params?: UsersParams): Promise<BitbucketUser[]> {\n const data = await this.request<PagedResponse<BitbucketUser>>(\n '/users',\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link UserResource} for a given user slug, providing access\n * to user data.\n *\n * The returned resource can be awaited directly to fetch user info.\n *\n * @param slug - The user slug (e.g., `'pilmee'`)\n * @returns A chainable user resource\n *\n * @example\n * ```typescript\n * const user = await bbClient.user('pilmee');\n * ```\n */\n user(slug: string): UserResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n return new UserResource(request, slug);\n }\n}\n\n/**\n * Appends query parameters to a URL string, skipping `undefined` values.\n * @internal\n */\nfunction buildUrl(base: string, params?: Record<string, string | number | boolean>): string {\n if (!params) return base;\n const entries = Object.entries(params).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return base;\n const search = new URLSearchParams(entries.map(([k, v]) => [k, String(v)]));\n return `${base}?${search.toString()}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,SAAS,SAAS,OAAuB;AACvC,MAAI,OAAO,SAAS,aAAa;AAC/B,WAAO,KAAK,KAAK;AAAA,EACnB;AACA,SAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAC7C;AAiBO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcpB,YAAY,QAAgB,MAAc,OAAe;AACvD,QAAI,CAAC,IAAI,SAAS,MAAM,GAAG;AACzB,YAAM,IAAI,UAAU,oBAAoB,MAAM,sBAAsB;AAAA,IACtE;AACA,SAAK,SAAS,OAAO,QAAQ,OAAO,EAAE;AACtC,SAAK,sBAAsB,SAAS,SAAS,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,yBAAiC;AAC/B,WAAO,KAAK;AAAA,EACd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B,CAAC,MAAM,WAAW,KAAK,YAAY,MAAM,MAAM;AAClF,WAAO,IAAI,gBAAgB,SAAS,aAAa,UAAU;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAM,QAAgD;AAC1D,UAAM,OAAO,MAAM,KAAK;AAAA,MACtB;AAAA,MACA;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,KAAK,MAA4B;AAC/B,UAAM,UAAqB,CACzB,MACA,WACG,KAAK,QAAW,MAAM,MAAM;AACjC,WAAO,IAAI,aAAa,SAAS,IAAI;AAAA,EACvC;AACF;AAMA,SAAS,SAAS,MAAc,QAA4D;AAC1F,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,UAAU,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS;AACxE,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,SAAS,IAAI,gBAAgB,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1E,SAAO,GAAG,IAAI,IAAI,OAAO,SAAS,CAAC;AACrC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/security/Security.ts","../src/resources/PullRequestResource.ts","../src/resources/RepositoryResource.ts","../src/resources/ProjectResource.ts","../src/errors/BitbucketApiError.ts","../src/resources/UserResource.ts","../src/BitbucketClient.ts"],"sourcesContent":["export { BitbucketClient } from './BitbucketClient';\nexport { BitbucketApiError } from './errors/BitbucketApiError';\nexport type { BitbucketClientOptions } from './BitbucketClient';\nexport { Security } from './security/Security';\nexport { ProjectResource } from './resources/ProjectResource';\nexport { RepositoryResource } from './resources/RepositoryResource';\nexport { PullRequestResource } from './resources/PullRequestResource';\nexport { UserResource } from './resources/UserResource';\nexport type { BitbucketProject, ProjectsParams } from './domain/Project';\nexport type { BitbucketRepository, ReposParams } from './domain/Repository';\nexport type { BitbucketPullRequest, BitbucketParticipant, BitbucketRef, PullRequestsParams } from './domain/PullRequest';\nexport type { BitbucketPullRequestActivity, BitbucketPullRequestComment, BitbucketActivityUser, PullRequestActivityAction, ActivitiesParams } from './domain/PullRequestActivity';\nexport type { BitbucketPullRequestTask, PullRequestTaskState, PullRequestTaskPermittedOperations, PullRequestTaskAnchor, TasksParams } from './domain/PullRequestTask';\nexport type { BitbucketChange, BitbucketChangePath, ChangeType, ChangeNodeType, ChangesParams } from './domain/Change';\nexport type { BitbucketReport, BitbucketReportData, ReportResult, ReportDataType, ReportsParams } from './domain/Report';\nexport type { BitbucketBuildSummaries, BitbucketBuildCount } from './domain/BuildSummary';\nexport type { BitbucketIssue } from './domain/Issue';\nexport type { BitbucketUser, BitbucketUserPermission, UsersParams, ProjectUsersParams } from './domain/User';\nexport type { BitbucketCommit, BitbucketCommitAuthor, CommitsParams } from './domain/Commit';\nexport type { BitbucketBranch, BranchesParams } from './domain/Branch';\nexport type { BitbucketTag, TagsParams } from './domain/Tag';\nexport type { BitbucketRepositorySize } from './domain/RepositorySize';\nexport type { BitbucketLastModifiedEntry, LastModifiedParams } from './domain/LastModified';\nexport type { RawFileParams } from './domain/RawFile';\nexport type { PaginationParams, PagedResponse } from './domain/Pagination';\n","/**\n * Encodes a string to Base64 in a way that works in both Node.js and browsers.\n * @internal\n */\nfunction toBase64(value: string): string {\n if (typeof btoa !== 'undefined') {\n return btoa(value);\n }\n return Buffer.from(value).toString('base64');\n}\n\n/**\n * Handles Basic Authentication for Bitbucket Data Center REST API requests.\n *\n * @example\n * ```typescript\n * const security = new Security(\n * 'https://bitbucket.example.com',\n * 'my-user',\n * 'my-token'\n * );\n *\n * const headers = security.getHeaders();\n * // { Authorization: 'Basic <base64>', 'Content-Type': 'application/json', Accept: 'application/json' }\n * ```\n */\nexport class Security {\n private readonly apiUrl: string;\n private readonly authorizationHeader: string;\n\n /**\n * Creates a new Security instance with Basic Authentication credentials.\n *\n * @param apiUrl - The base URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`).\n * Must be a valid URL; throws if it cannot be parsed.\n * @param user - The username to authenticate with\n * @param token - The personal access token or password to authenticate with\n *\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor(apiUrl: string, user: string, token: string) {\n if (!URL.canParse(apiUrl)) {\n throw new TypeError(`Invalid apiUrl: \"${apiUrl}\" is not a valid URL`);\n }\n this.apiUrl = apiUrl.replace(/\\/$/, '');\n this.authorizationHeader = `Basic ${toBase64(`${user}:${token}`)}`;\n }\n\n /**\n * Returns the base URL of the Bitbucket Data Center instance, without a trailing slash.\n *\n * @returns The API base URL\n */\n getApiUrl(): string {\n return this.apiUrl;\n }\n\n /**\n * Returns the value of the `Authorization` header for Basic Authentication.\n *\n * @returns The Authorization header value in the format `Basic <base64-encoded-credentials>`\n */\n getAuthorizationHeader(): string {\n return this.authorizationHeader;\n }\n\n /**\n * Returns the full set of HTTP headers required for authenticated API requests.\n *\n * @returns An object containing `Authorization`, `Content-Type`, and `Accept` headers\n */\n getHeaders(): Record<string, string> {\n return {\n Authorization: this.authorizationHeader,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n","import type { BitbucketPullRequest } from '../domain/PullRequest';\nimport type { BitbucketPullRequestActivity, ActivitiesParams } from '../domain/PullRequestActivity';\nimport type { BitbucketPullRequestTask, TasksParams } from '../domain/PullRequestTask';\nimport type { BitbucketCommit } from '../domain/Commit';\nimport type { BitbucketChange, ChangesParams } from '../domain/Change';\nimport type { BitbucketReport, ReportsParams } from '../domain/Report';\nimport type { BitbucketBuildSummaries } from '../domain/BuildSummary';\nimport type { BitbucketIssue } from '../domain/Issue';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket pull request resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketPullRequest>` so it can be awaited directly\n * to fetch the pull request info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get pull request info\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n *\n * // Get activities\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get tasks\n * const tasks = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).tasks();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).commits();\n *\n * // Get changes\n * const changes = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).changes();\n *\n * // Get reports\n * const reports = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).reports();\n *\n * // Get build summaries\n * const builds = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();\n *\n * // Get linked Jira issues\n * const issues = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).issues();\n * ```\n */\nexport class PullRequestResource implements PromiseLike<BitbucketPullRequest> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n projectKey: string,\n repoSlug: string,\n pullRequestId: number,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}/pull-requests/${pullRequestId}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the pull request info.\n * Delegates to {@link PullRequestResource.get}.\n */\n then<TResult1 = BitbucketPullRequest, TResult2 = never>(\n onfulfilled?: ((value: BitbucketPullRequest) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the pull request details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}`\n *\n * @returns The pull request object\n */\n async get(): Promise<BitbucketPullRequest> {\n return this.request<BitbucketPullRequest>(this.basePath);\n }\n\n /**\n * Fetches the activity feed for this pull request.\n *\n * Activities include comments, approvals, reviews, rescopes, merges, and declines.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/activities`\n *\n * @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`\n * @returns An array of pull request activities, ordered from most recent to oldest\n */\n async activities(params?: ActivitiesParams): Promise<PagedResponse<BitbucketPullRequestActivity>> {\n return this.request<PagedResponse<BitbucketPullRequestActivity>>(\n `${this.basePath}/activities`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the tasks (review to-do items) for this pull request.\n *\n * Tasks are created by reviewers on specific comments and can be `OPEN` or `RESOLVED`.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/tasks`\n *\n * @param params - Optional filters: `limit`, `start`\n * @returns An array of pull request tasks\n */\n async tasks(params?: TasksParams): Promise<PagedResponse<BitbucketPullRequestTask>> {\n return this.request<PagedResponse<BitbucketPullRequestTask>>(\n `${this.basePath}/tasks`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the commits included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/commits`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of commits\n */\n async commits(params?: PaginationParams): Promise<PagedResponse<BitbucketCommit>> {\n return this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the file changes included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/changes`\n *\n * @param params - Optional filters: `limit`, `start`, `withComments`\n * @returns An array of file changes\n */\n async changes(params?: ChangesParams): Promise<PagedResponse<BitbucketChange>> {\n return this.request<PagedResponse<BitbucketChange>>(\n `${this.basePath}/changes`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the Code Insights reports for this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/reports`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of Code Insights reports\n */\n async reports(params?: ReportsParams): Promise<PagedResponse<BitbucketReport>> {\n return this.request<PagedResponse<BitbucketReport>>(\n `${this.basePath}/reports`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the aggregated build summaries for this pull request.\n *\n * Returns a map of commit hash → build counts per state\n * (`successful`, `failed`, `inProgress`, `cancelled`, `unknown`).\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/build-summaries`\n *\n * @returns A record keyed by commit SHA with aggregated build counts\n */\n async buildSummaries(): Promise<BitbucketBuildSummaries> {\n return this.request<BitbucketBuildSummaries>(`${this.basePath}/build-summaries`);\n }\n\n /**\n * Fetches the Jira issues linked to this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/issues`\n *\n * @returns An array of linked Jira issues\n */\n async issues(): Promise<BitbucketIssue[]> {\n return this.request<BitbucketIssue[]>(`${this.basePath}/issues`);\n }\n}\n","import type { BitbucketRepository } from '../domain/Repository';\nimport type { BitbucketPullRequest, PullRequestsParams } from '../domain/PullRequest';\nimport type { BitbucketCommit, CommitsParams } from '../domain/Commit';\nimport type { BitbucketBranch, BranchesParams } from '../domain/Branch';\nimport type { BitbucketTag, TagsParams } from '../domain/Tag';\nimport type { BitbucketRepositorySize } from '../domain/RepositorySize';\nimport type { BitbucketLastModifiedEntry, LastModifiedParams } from '../domain/LastModified';\nimport type { RawFileParams } from '../domain/RawFile';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn, RequestTextFn } from './ProjectResource';\nimport { PullRequestResource } from './PullRequestResource';\n\n/**\n * Represents a Bitbucket repository resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketRepository>` so it can be awaited directly\n * to fetch repository info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get repository info\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n *\n * // Get pull requests\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n *\n * // Navigate into a specific pull request\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\nexport class RepositoryResource implements PromiseLike<BitbucketRepository> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly projectKey: string,\n private readonly repoSlug: string,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the repository info.\n * Delegates to {@link RepositoryResource.get}.\n */\n then<TResult1 = BitbucketRepository, TResult2 = never>(\n onfulfilled?: ((value: BitbucketRepository) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the repository details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}`\n *\n * @returns The repository object\n */\n async get(): Promise<BitbucketRepository> {\n return this.request<BitbucketRepository>(this.basePath);\n }\n\n /**\n * Fetches pull requests for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests`\n *\n * @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`\n * @returns An array of pull requests\n */\n async pullRequests(params?: PullRequestsParams): Promise<PagedResponse<BitbucketPullRequest>> {\n return this.request<PagedResponse<BitbucketPullRequest>>(\n `${this.basePath}/pull-requests`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches commits for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/commits`\n *\n * @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`\n * @returns An array of commits\n */\n async commits(params?: CommitsParams): Promise<PagedResponse<BitbucketCommit>> {\n return this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the files last modified in this repository along with the commit that last touched each.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/last-modified`\n *\n * @param params - Optional filters: `limit`, `start`, `at`\n * @returns An array of last-modified entries\n */\n async lastModified(params?: LastModifiedParams): Promise<PagedResponse<BitbucketLastModifiedEntry>> {\n return this.request<PagedResponse<BitbucketLastModifiedEntry>>(\n `${this.basePath}/last-modified`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the size of this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/sizes`\n *\n * @returns The repository size object\n */\n async size(): Promise<BitbucketRepositorySize> {\n return this.request<BitbucketRepositorySize>(`${this.basePath}/sizes`);\n }\n\n /**\n * Fetches branches for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/branches`\n *\n * @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`\n * @returns An array of branches\n */\n async branches(params?: BranchesParams): Promise<PagedResponse<BitbucketBranch>> {\n return this.request<PagedResponse<BitbucketBranch>>(\n `${this.basePath}/branches`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the forks of this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/forks`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns A paged response of forked repositories\n */\n async forks(params?: PaginationParams): Promise<PagedResponse<BitbucketRepository>> {\n return this.request<PagedResponse<BitbucketRepository>>(\n `${this.basePath}/forks`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches tags for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/tags`\n *\n * @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`\n * @returns A paged response of tags\n */\n async tags(params?: TagsParams): Promise<PagedResponse<BitbucketTag>> {\n return this.request<PagedResponse<BitbucketTag>>(\n `${this.basePath}/tags`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link PullRequestResource} for a given pull request ID, providing\n * access to pull request data and sub-resources (activities, etc.).\n *\n * The returned resource can be awaited directly to fetch pull request info,\n * or chained to access nested resources.\n *\n * @param pullRequestId - The numeric pull request ID\n * @returns A chainable pull request resource\n *\n * @example\n * ```typescript\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n * ```\n */\n /**\n * Fetches the raw content of a file in this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}`\n *\n * @param filePath - Path to the file (e.g., `'src/index.ts'`)\n * @param params - Optional: `at` (branch, tag, or commit SHA)\n * @returns The raw file content as a string\n */\n async raw(filePath: string, params?: RawFileParams): Promise<string> {\n return this.requestText(\n `${this.basePath}/raw/${filePath}`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n pullRequest(pullRequestId: number): PullRequestResource {\n return new PullRequestResource(this.request, this.projectKey, this.repoSlug, pullRequestId);\n }\n}\n","import type { BitbucketProject } from '../domain/Project';\nimport type { BitbucketRepository, ReposParams } from '../domain/Repository';\nimport type { BitbucketUserPermission, ProjectUsersParams } from '../domain/User';\nimport type { PagedResponse } from '../domain/Pagination';\nimport { RepositoryResource } from './RepositoryResource';\n\n/** @internal */\nexport type RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<T>;\n\n/** @internal */\nexport type RequestTextFn = (\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<string>;\n\n/**\n * Represents a Bitbucket project resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketProject>` so it can be awaited directly\n * to fetch the project info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get project info\n * const project = await bbClient.project('PROJ');\n *\n * // Get repositories with filters\n * const repos = await bbClient.project('PROJ').repos({ limit: 50, name: 'api' });\n *\n * // Navigate into a specific repository\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n *\n * // Get users with access to the project\n * const users = await bbClient.project('PROJ').users({ permission: 'PROJECT_WRITE' });\n * ```\n */\nexport class ProjectResource implements PromiseLike<BitbucketProject> {\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly key: string,\n ) {}\n\n /**\n * Allows the resource to be awaited directly, resolving with the project info.\n * Delegates to {@link ProjectResource.get}.\n */\n then<TResult1 = BitbucketProject, TResult2 = never>(\n onfulfilled?: ((value: BitbucketProject) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the project details.\n *\n * `GET /rest/api/latest/projects/{key}`\n *\n * @returns The project object\n */\n async get(): Promise<BitbucketProject> {\n return this.request<BitbucketProject>(`/projects/${this.key}`);\n }\n\n /**\n * Fetches repositories belonging to this project.\n *\n * `GET /rest/api/latest/projects/{key}/repos`\n *\n * @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`\n * @returns An array of repositories\n */\n async repos(params?: ReposParams): Promise<PagedResponse<BitbucketRepository>> {\n return this.request<PagedResponse<BitbucketRepository>>(\n `/projects/${this.key}/repos`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link RepositoryResource} for a given repository slug, providing\n * access to repository-level data and sub-resources (pull requests, commits, etc.).\n *\n * The returned resource can be awaited directly to fetch repository info,\n * or chained to access nested resources.\n *\n * @param repoSlug - The repository slug (e.g., `'my-repo'`)\n * @returns A chainable repository resource\n *\n * @example\n * ```typescript\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\n repo(repoSlug: string): RepositoryResource {\n return new RepositoryResource(this.request, this.requestText, this.key, repoSlug);\n }\n\n /**\n * Fetches users with explicit permissions on this project.\n *\n * `GET /rest/api/latest/projects/{key}/permissions/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`, `permission`\n * @returns An array of user–permission pairs\n */\n async users(params?: ProjectUsersParams): Promise<PagedResponse<BitbucketUserPermission>> {\n return this.request<PagedResponse<BitbucketUserPermission>>(\n `/projects/${this.key}/permissions/users`,\n params as Record<string, string | number | boolean>,\n );\n }\n}\n","/**\n * Thrown when the Bitbucket Data Center API returns a non-2xx response.\n *\n * @example\n * ```typescript\n * import { BitbucketApiError } from 'bitbucket-datacenter-api-client';\n *\n * try {\n * await bb.project('NONEXISTENT');\n * } catch (err) {\n * if (err instanceof BitbucketApiError) {\n * console.log(err.status); // 404\n * console.log(err.statusText); // 'Not Found'\n * console.log(err.message); // 'Bitbucket API error: 404 Not Found'\n * }\n * }\n * ```\n */\nexport class BitbucketApiError extends Error {\n /** HTTP status code (e.g. `404`, `401`, `403`) */\n readonly status: number;\n /** HTTP status text (e.g. `'Not Found'`, `'Unauthorized'`) */\n readonly statusText: string;\n\n constructor(status: number, statusText: string) {\n super(`Bitbucket API error: ${status} ${statusText}`);\n this.name = 'BitbucketApiError';\n this.status = status;\n this.statusText = statusText;\n }\n}\n","import type { BitbucketUser } from '../domain/User';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket user resource.\n *\n * Implements `PromiseLike<BitbucketUser>` so it can be awaited directly\n * to fetch user info.\n *\n * @example\n * ```typescript\n * // Await directly to get user info\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class UserResource implements PromiseLike<BitbucketUser> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n slug: string,\n ) {\n this.basePath = `/users/${slug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the user info.\n * Delegates to {@link UserResource.get}.\n */\n then<TResult1 = BitbucketUser, TResult2 = never>(\n onfulfilled?: ((value: BitbucketUser) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the user details.\n *\n * `GET /rest/api/latest/users/{slug}`\n *\n * @returns The user object\n */\n async get(): Promise<BitbucketUser> {\n return this.request<BitbucketUser>(this.basePath);\n }\n}\n","import { Security } from './security/Security';\nimport { ProjectResource, type RequestFn, type RequestTextFn } from './resources/ProjectResource';\nimport { BitbucketApiError } from './errors/BitbucketApiError';\nimport { UserResource } from './resources/UserResource';\nimport type { BitbucketProject, ProjectsParams } from './domain/Project';\nimport type { BitbucketUser, UsersParams } from './domain/User';\nimport type { PagedResponse } from './domain/Pagination';\n\n/**\n * Constructor options for {@link BitbucketClient}.\n */\nexport interface BitbucketClientOptions {\n /** The host URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`) */\n apiUrl: string;\n /** The API path to prepend to every request (e.g., `'rest/api/latest'`) */\n apiPath: string;\n /** The username to authenticate with */\n user: string;\n /** The personal access token or password to authenticate with */\n token: string;\n}\n\n/**\n * Main entry point for the Bitbucket Data Center REST API client.\n *\n * @example\n * ```typescript\n * const bbClient = new BitbucketClient({\n * apiUrl: 'https://bitbucket.example.com',\n * apiPath: 'rest/api/latest',\n * user: 'pilmee',\n * token: 'my-token',\n * });\n *\n * const projects = await bbClient.projects({ limit: 50 });\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ name: 'api' });\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * const users = await bbClient.users({ filter: 'john' });\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class BitbucketClient {\n private readonly security: Security;\n private readonly apiPath: string;\n\n /**\n * @param options - Connection and authentication options\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor({ apiUrl, apiPath, user, token }: BitbucketClientOptions) {\n this.security = new Security(apiUrl, user, token);\n this.apiPath = apiPath.replace(/^\\/|\\/$/g, '');\n }\n\n /**\n * Performs an authenticated GET request to the Bitbucket REST API.\n *\n * @param path - API path appended directly to `apiUrl` (e.g., `'/projects'`)\n * @param params - Optional query parameters to append to the URL\n * @throws {Error} If the HTTP response is not OK\n * @internal\n */\n private async request<T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<T> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new BitbucketApiError(response.status, response.statusText);\n }\n return response.json() as Promise<T>;\n }\n\n private async requestText(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<string> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new BitbucketApiError(response.status, response.statusText);\n }\n return response.text();\n }\n\n /**\n * Fetches all projects accessible to the authenticated user.\n *\n * `GET /rest/api/latest/projects`\n *\n * @param params - Optional filters: `limit`, `start`, `name`, `permission`\n * @returns An array of projects\n */\n async projects(params?: ProjectsParams): Promise<PagedResponse<BitbucketProject>> {\n return this.request<PagedResponse<BitbucketProject>>(\n '/projects',\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link ProjectResource} for a given project key, providing access\n * to project-level data and sub-resources.\n *\n * The returned resource can be awaited directly to fetch project info,\n * or chained to access nested resources.\n *\n * @param projectKey - The project key (e.g., `'PROJ'`)\n * @returns A chainable project resource\n *\n * @example\n * ```typescript\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ limit: 10 });\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n * ```\n */\n project(projectKey: string): ProjectResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n const requestText: RequestTextFn = (path, params) => this.requestText(path, params);\n return new ProjectResource(request, requestText, projectKey);\n }\n\n /**\n * Fetches all users accessible to the authenticated user.\n *\n * `GET /rest/api/latest/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`\n * @returns An array of users\n */\n async users(params?: UsersParams): Promise<PagedResponse<BitbucketUser>> {\n return this.request<PagedResponse<BitbucketUser>>(\n '/users',\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link UserResource} for a given user slug, providing access\n * to user data.\n *\n * The returned resource can be awaited directly to fetch user info.\n *\n * @param slug - The user slug (e.g., `'pilmee'`)\n * @returns A chainable user resource\n *\n * @example\n * ```typescript\n * const user = await bbClient.user('pilmee');\n * ```\n */\n user(slug: string): UserResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n return new UserResource(request, slug);\n }\n}\n\n/**\n * Appends query parameters to a URL string, skipping `undefined` values.\n * @internal\n */\nfunction buildUrl(base: string, params?: Record<string, string | number | boolean>): string {\n if (!params) return base;\n const entries = Object.entries(params).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return base;\n const search = new URLSearchParams(entries.map(([k, v]) => [k, String(v)]));\n return `${base}?${search.toString()}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,SAAS,SAAS,OAAuB;AACvC,MAAI,OAAO,SAAS,aAAa;AAC/B,WAAO,KAAK,KAAK;AAAA,EACnB;AACA,SAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAC7C;AAiBO,IAAM,WAAN,M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AI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,SAAS,IAAI,gBAAgB,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1E,SAAO,GAAG,IAAI,IAAI,OAAO,SAAS,CAAC;AACrC;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -88,11 +88,10 @@ var PullRequestResource = class {
|
|
|
88
88
|
* @returns An array of pull request activities, ordered from most recent to oldest
|
|
89
89
|
*/
|
|
90
90
|
async activities(params) {
|
|
91
|
-
|
|
91
|
+
return this.request(
|
|
92
92
|
`${this.basePath}/activities`,
|
|
93
93
|
params
|
|
94
94
|
);
|
|
95
|
-
return data.values;
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
97
|
* Fetches the tasks (review to-do items) for this pull request.
|
|
@@ -105,11 +104,10 @@ var PullRequestResource = class {
|
|
|
105
104
|
* @returns An array of pull request tasks
|
|
106
105
|
*/
|
|
107
106
|
async tasks(params) {
|
|
108
|
-
|
|
107
|
+
return this.request(
|
|
109
108
|
`${this.basePath}/tasks`,
|
|
110
109
|
params
|
|
111
110
|
);
|
|
112
|
-
return data.values;
|
|
113
111
|
}
|
|
114
112
|
/**
|
|
115
113
|
* Fetches the commits included in this pull request.
|
|
@@ -120,11 +118,10 @@ var PullRequestResource = class {
|
|
|
120
118
|
* @returns An array of commits
|
|
121
119
|
*/
|
|
122
120
|
async commits(params) {
|
|
123
|
-
|
|
121
|
+
return this.request(
|
|
124
122
|
`${this.basePath}/commits`,
|
|
125
123
|
params
|
|
126
124
|
);
|
|
127
|
-
return data.values;
|
|
128
125
|
}
|
|
129
126
|
/**
|
|
130
127
|
* Fetches the file changes included in this pull request.
|
|
@@ -135,11 +132,10 @@ var PullRequestResource = class {
|
|
|
135
132
|
* @returns An array of file changes
|
|
136
133
|
*/
|
|
137
134
|
async changes(params) {
|
|
138
|
-
|
|
135
|
+
return this.request(
|
|
139
136
|
`${this.basePath}/changes`,
|
|
140
137
|
params
|
|
141
138
|
);
|
|
142
|
-
return data.values;
|
|
143
139
|
}
|
|
144
140
|
/**
|
|
145
141
|
* Fetches the Code Insights reports for this pull request.
|
|
@@ -150,11 +146,10 @@ var PullRequestResource = class {
|
|
|
150
146
|
* @returns An array of Code Insights reports
|
|
151
147
|
*/
|
|
152
148
|
async reports(params) {
|
|
153
|
-
|
|
149
|
+
return this.request(
|
|
154
150
|
`${this.basePath}/reports`,
|
|
155
151
|
params
|
|
156
152
|
);
|
|
157
|
-
return data.values;
|
|
158
153
|
}
|
|
159
154
|
/**
|
|
160
155
|
* Fetches the aggregated build summaries for this pull request.
|
|
@@ -217,11 +212,10 @@ var RepositoryResource = class {
|
|
|
217
212
|
* @returns An array of pull requests
|
|
218
213
|
*/
|
|
219
214
|
async pullRequests(params) {
|
|
220
|
-
|
|
215
|
+
return this.request(
|
|
221
216
|
`${this.basePath}/pull-requests`,
|
|
222
217
|
params
|
|
223
218
|
);
|
|
224
|
-
return data.values;
|
|
225
219
|
}
|
|
226
220
|
/**
|
|
227
221
|
* Fetches commits for this repository.
|
|
@@ -232,11 +226,10 @@ var RepositoryResource = class {
|
|
|
232
226
|
* @returns An array of commits
|
|
233
227
|
*/
|
|
234
228
|
async commits(params) {
|
|
235
|
-
|
|
229
|
+
return this.request(
|
|
236
230
|
`${this.basePath}/commits`,
|
|
237
231
|
params
|
|
238
232
|
);
|
|
239
|
-
return data.values;
|
|
240
233
|
}
|
|
241
234
|
/**
|
|
242
235
|
* Fetches the files last modified in this repository along with the commit that last touched each.
|
|
@@ -247,11 +240,10 @@ var RepositoryResource = class {
|
|
|
247
240
|
* @returns An array of last-modified entries
|
|
248
241
|
*/
|
|
249
242
|
async lastModified(params) {
|
|
250
|
-
|
|
243
|
+
return this.request(
|
|
251
244
|
`${this.basePath}/last-modified`,
|
|
252
245
|
params
|
|
253
246
|
);
|
|
254
|
-
return data.values;
|
|
255
247
|
}
|
|
256
248
|
/**
|
|
257
249
|
* Fetches the size of this repository.
|
|
@@ -272,11 +264,38 @@ var RepositoryResource = class {
|
|
|
272
264
|
* @returns An array of branches
|
|
273
265
|
*/
|
|
274
266
|
async branches(params) {
|
|
275
|
-
|
|
267
|
+
return this.request(
|
|
276
268
|
`${this.basePath}/branches`,
|
|
277
269
|
params
|
|
278
270
|
);
|
|
279
|
-
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Fetches the forks of this repository.
|
|
274
|
+
*
|
|
275
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/forks`
|
|
276
|
+
*
|
|
277
|
+
* @param params - Optional pagination: `limit`, `start`
|
|
278
|
+
* @returns A paged response of forked repositories
|
|
279
|
+
*/
|
|
280
|
+
async forks(params) {
|
|
281
|
+
return this.request(
|
|
282
|
+
`${this.basePath}/forks`,
|
|
283
|
+
params
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Fetches tags for this repository.
|
|
288
|
+
*
|
|
289
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/tags`
|
|
290
|
+
*
|
|
291
|
+
* @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`
|
|
292
|
+
* @returns A paged response of tags
|
|
293
|
+
*/
|
|
294
|
+
async tags(params) {
|
|
295
|
+
return this.request(
|
|
296
|
+
`${this.basePath}/tags`,
|
|
297
|
+
params
|
|
298
|
+
);
|
|
280
299
|
}
|
|
281
300
|
/**
|
|
282
301
|
* Returns a {@link PullRequestResource} for a given pull request ID, providing
|
|
@@ -348,11 +367,10 @@ var ProjectResource = class {
|
|
|
348
367
|
* @returns An array of repositories
|
|
349
368
|
*/
|
|
350
369
|
async repos(params) {
|
|
351
|
-
|
|
370
|
+
return this.request(
|
|
352
371
|
`/projects/${this.key}/repos`,
|
|
353
372
|
params
|
|
354
373
|
);
|
|
355
|
-
return data.values;
|
|
356
374
|
}
|
|
357
375
|
/**
|
|
358
376
|
* Returns a {@link RepositoryResource} for a given repository slug, providing
|
|
@@ -383,11 +401,20 @@ var ProjectResource = class {
|
|
|
383
401
|
* @returns An array of user–permission pairs
|
|
384
402
|
*/
|
|
385
403
|
async users(params) {
|
|
386
|
-
|
|
404
|
+
return this.request(
|
|
387
405
|
`/projects/${this.key}/permissions/users`,
|
|
388
406
|
params
|
|
389
407
|
);
|
|
390
|
-
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/errors/BitbucketApiError.ts
|
|
412
|
+
var BitbucketApiError = class extends Error {
|
|
413
|
+
constructor(status, statusText) {
|
|
414
|
+
super(`Bitbucket API error: ${status} ${statusText}`);
|
|
415
|
+
this.name = "BitbucketApiError";
|
|
416
|
+
this.status = status;
|
|
417
|
+
this.statusText = statusText;
|
|
391
418
|
}
|
|
392
419
|
};
|
|
393
420
|
|
|
@@ -440,7 +467,7 @@ var BitbucketClient = class {
|
|
|
440
467
|
const url = buildUrl(base, params);
|
|
441
468
|
const response = await fetch(url, { headers: this.security.getHeaders() });
|
|
442
469
|
if (!response.ok) {
|
|
443
|
-
throw new
|
|
470
|
+
throw new BitbucketApiError(response.status, response.statusText);
|
|
444
471
|
}
|
|
445
472
|
return response.json();
|
|
446
473
|
}
|
|
@@ -449,7 +476,7 @@ var BitbucketClient = class {
|
|
|
449
476
|
const url = buildUrl(base, params);
|
|
450
477
|
const response = await fetch(url, { headers: this.security.getHeaders() });
|
|
451
478
|
if (!response.ok) {
|
|
452
|
-
throw new
|
|
479
|
+
throw new BitbucketApiError(response.status, response.statusText);
|
|
453
480
|
}
|
|
454
481
|
return response.text();
|
|
455
482
|
}
|
|
@@ -462,11 +489,10 @@ var BitbucketClient = class {
|
|
|
462
489
|
* @returns An array of projects
|
|
463
490
|
*/
|
|
464
491
|
async projects(params) {
|
|
465
|
-
|
|
492
|
+
return this.request(
|
|
466
493
|
"/projects",
|
|
467
494
|
params
|
|
468
495
|
);
|
|
469
|
-
return data.values;
|
|
470
496
|
}
|
|
471
497
|
/**
|
|
472
498
|
* Returns a {@link ProjectResource} for a given project key, providing access
|
|
@@ -499,11 +525,10 @@ var BitbucketClient = class {
|
|
|
499
525
|
* @returns An array of users
|
|
500
526
|
*/
|
|
501
527
|
async users(params) {
|
|
502
|
-
|
|
528
|
+
return this.request(
|
|
503
529
|
"/users",
|
|
504
530
|
params
|
|
505
531
|
);
|
|
506
|
-
return data.values;
|
|
507
532
|
}
|
|
508
533
|
/**
|
|
509
534
|
* Returns a {@link UserResource} for a given user slug, providing access
|
|
@@ -532,6 +557,7 @@ function buildUrl(base, params) {
|
|
|
532
557
|
return `${base}?${search.toString()}`;
|
|
533
558
|
}
|
|
534
559
|
export {
|
|
560
|
+
BitbucketApiError,
|
|
535
561
|
BitbucketClient,
|
|
536
562
|
ProjectResource,
|
|
537
563
|
PullRequestResource,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/security/Security.ts","../src/resources/PullRequestResource.ts","../src/resources/RepositoryResource.ts","../src/resources/ProjectResource.ts","../src/resources/UserResource.ts","../src/BitbucketClient.ts"],"sourcesContent":["/**\n * Encodes a string to Base64 in a way that works in both Node.js and browsers.\n * @internal\n */\nfunction toBase64(value: string): string {\n if (typeof btoa !== 'undefined') {\n return btoa(value);\n }\n return Buffer.from(value).toString('base64');\n}\n\n/**\n * Handles Basic Authentication for Bitbucket Data Center REST API requests.\n *\n * @example\n * ```typescript\n * const security = new Security(\n * 'https://bitbucket.example.com',\n * 'my-user',\n * 'my-token'\n * );\n *\n * const headers = security.getHeaders();\n * // { Authorization: 'Basic <base64>', 'Content-Type': 'application/json', Accept: 'application/json' }\n * ```\n */\nexport class Security {\n private readonly apiUrl: string;\n private readonly authorizationHeader: string;\n\n /**\n * Creates a new Security instance with Basic Authentication credentials.\n *\n * @param apiUrl - The base URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`).\n * Must be a valid URL; throws if it cannot be parsed.\n * @param user - The username to authenticate with\n * @param token - The personal access token or password to authenticate with\n *\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor(apiUrl: string, user: string, token: string) {\n if (!URL.canParse(apiUrl)) {\n throw new TypeError(`Invalid apiUrl: \"${apiUrl}\" is not a valid URL`);\n }\n this.apiUrl = apiUrl.replace(/\\/$/, '');\n this.authorizationHeader = `Basic ${toBase64(`${user}:${token}`)}`;\n }\n\n /**\n * Returns the base URL of the Bitbucket Data Center instance, without a trailing slash.\n *\n * @returns The API base URL\n */\n getApiUrl(): string {\n return this.apiUrl;\n }\n\n /**\n * Returns the value of the `Authorization` header for Basic Authentication.\n *\n * @returns The Authorization header value in the format `Basic <base64-encoded-credentials>`\n */\n getAuthorizationHeader(): string {\n return this.authorizationHeader;\n }\n\n /**\n * Returns the full set of HTTP headers required for authenticated API requests.\n *\n * @returns An object containing `Authorization`, `Content-Type`, and `Accept` headers\n */\n getHeaders(): Record<string, string> {\n return {\n Authorization: this.authorizationHeader,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n","import type { BitbucketPullRequest } from '../domain/PullRequest';\nimport type { BitbucketPullRequestActivity, ActivitiesParams } from '../domain/PullRequestActivity';\nimport type { BitbucketPullRequestTask, TasksParams } from '../domain/PullRequestTask';\nimport type { BitbucketCommit } from '../domain/Commit';\nimport type { BitbucketChange, ChangesParams } from '../domain/Change';\nimport type { BitbucketReport, ReportsParams } from '../domain/Report';\nimport type { BitbucketBuildSummaries } from '../domain/BuildSummary';\nimport type { BitbucketIssue } from '../domain/Issue';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket pull request resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketPullRequest>` so it can be awaited directly\n * to fetch the pull request info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get pull request info\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n *\n * // Get activities\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get tasks\n * const tasks = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).tasks();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).commits();\n *\n * // Get changes\n * const changes = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).changes();\n *\n * // Get reports\n * const reports = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).reports();\n *\n * // Get build summaries\n * const builds = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();\n *\n * // Get linked Jira issues\n * const issues = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).issues();\n * ```\n */\nexport class PullRequestResource implements PromiseLike<BitbucketPullRequest> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n projectKey: string,\n repoSlug: string,\n pullRequestId: number,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}/pull-requests/${pullRequestId}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the pull request info.\n * Delegates to {@link PullRequestResource.get}.\n */\n then<TResult1 = BitbucketPullRequest, TResult2 = never>(\n onfulfilled?: ((value: BitbucketPullRequest) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the pull request details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}`\n *\n * @returns The pull request object\n */\n async get(): Promise<BitbucketPullRequest> {\n return this.request<BitbucketPullRequest>(this.basePath);\n }\n\n /**\n * Fetches the activity feed for this pull request.\n *\n * Activities include comments, approvals, reviews, rescopes, merges, and declines.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/activities`\n *\n * @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`\n * @returns An array of pull request activities, ordered from most recent to oldest\n */\n async activities(params?: ActivitiesParams): Promise<BitbucketPullRequestActivity[]> {\n const data = await this.request<PagedResponse<BitbucketPullRequestActivity>>(\n `${this.basePath}/activities`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the tasks (review to-do items) for this pull request.\n *\n * Tasks are created by reviewers on specific comments and can be `OPEN` or `RESOLVED`.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/tasks`\n *\n * @param params - Optional filters: `limit`, `start`\n * @returns An array of pull request tasks\n */\n async tasks(params?: TasksParams): Promise<BitbucketPullRequestTask[]> {\n const data = await this.request<PagedResponse<BitbucketPullRequestTask>>(\n `${this.basePath}/tasks`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the commits included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/commits`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of commits\n */\n async commits(params?: PaginationParams): Promise<BitbucketCommit[]> {\n const data = await this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the file changes included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/changes`\n *\n * @param params - Optional filters: `limit`, `start`, `withComments`\n * @returns An array of file changes\n */\n async changes(params?: ChangesParams): Promise<BitbucketChange[]> {\n const data = await this.request<PagedResponse<BitbucketChange>>(\n `${this.basePath}/changes`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the Code Insights reports for this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/reports`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of Code Insights reports\n */\n async reports(params?: ReportsParams): Promise<BitbucketReport[]> {\n const data = await this.request<PagedResponse<BitbucketReport>>(\n `${this.basePath}/reports`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the aggregated build summaries for this pull request.\n *\n * Returns a map of commit hash → build counts per state\n * (`successful`, `failed`, `inProgress`, `cancelled`, `unknown`).\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/build-summaries`\n *\n * @returns A record keyed by commit SHA with aggregated build counts\n */\n async buildSummaries(): Promise<BitbucketBuildSummaries> {\n return this.request<BitbucketBuildSummaries>(`${this.basePath}/build-summaries`);\n }\n\n /**\n * Fetches the Jira issues linked to this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/issues`\n *\n * @returns An array of linked Jira issues\n */\n async issues(): Promise<BitbucketIssue[]> {\n return this.request<BitbucketIssue[]>(`${this.basePath}/issues`);\n }\n}\n","import type { BitbucketRepository } from '../domain/Repository';\nimport type { BitbucketPullRequest, PullRequestsParams } from '../domain/PullRequest';\nimport type { BitbucketCommit, CommitsParams } from '../domain/Commit';\nimport type { BitbucketBranch, BranchesParams } from '../domain/Branch';\nimport type { BitbucketRepositorySize } from '../domain/RepositorySize';\nimport type { BitbucketLastModifiedEntry, LastModifiedParams } from '../domain/LastModified';\nimport type { RawFileParams } from '../domain/RawFile';\nimport type { PagedResponse } from '../domain/Pagination';\nimport type { RequestFn, RequestTextFn } from './ProjectResource';\nimport { PullRequestResource } from './PullRequestResource';\n\n/**\n * Represents a Bitbucket repository resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketRepository>` so it can be awaited directly\n * to fetch repository info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get repository info\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n *\n * // Get pull requests\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n *\n * // Navigate into a specific pull request\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\nexport class RepositoryResource implements PromiseLike<BitbucketRepository> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly projectKey: string,\n private readonly repoSlug: string,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the repository info.\n * Delegates to {@link RepositoryResource.get}.\n */\n then<TResult1 = BitbucketRepository, TResult2 = never>(\n onfulfilled?: ((value: BitbucketRepository) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the repository details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}`\n *\n * @returns The repository object\n */\n async get(): Promise<BitbucketRepository> {\n return this.request<BitbucketRepository>(this.basePath);\n }\n\n /**\n * Fetches pull requests for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests`\n *\n * @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`\n * @returns An array of pull requests\n */\n async pullRequests(params?: PullRequestsParams): Promise<BitbucketPullRequest[]> {\n const data = await this.request<PagedResponse<BitbucketPullRequest>>(\n `${this.basePath}/pull-requests`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches commits for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/commits`\n *\n * @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`\n * @returns An array of commits\n */\n async commits(params?: CommitsParams): Promise<BitbucketCommit[]> {\n const data = await this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the files last modified in this repository along with the commit that last touched each.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/last-modified`\n *\n * @param params - Optional filters: `limit`, `start`, `at`\n * @returns An array of last-modified entries\n */\n async lastModified(params?: LastModifiedParams): Promise<BitbucketLastModifiedEntry[]> {\n const data = await this.request<PagedResponse<BitbucketLastModifiedEntry>>(\n `${this.basePath}/last-modified`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Fetches the size of this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/sizes`\n *\n * @returns The repository size object\n */\n async size(): Promise<BitbucketRepositorySize> {\n return this.request<BitbucketRepositorySize>(`${this.basePath}/sizes`);\n }\n\n /**\n * Fetches branches for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/branches`\n *\n * @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`\n * @returns An array of branches\n */\n async branches(params?: BranchesParams): Promise<BitbucketBranch[]> {\n const data = await this.request<PagedResponse<BitbucketBranch>>(\n `${this.basePath}/branches`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link PullRequestResource} for a given pull request ID, providing\n * access to pull request data and sub-resources (activities, etc.).\n *\n * The returned resource can be awaited directly to fetch pull request info,\n * or chained to access nested resources.\n *\n * @param pullRequestId - The numeric pull request ID\n * @returns A chainable pull request resource\n *\n * @example\n * ```typescript\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n * ```\n */\n /**\n * Fetches the raw content of a file in this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}`\n *\n * @param filePath - Path to the file (e.g., `'src/index.ts'`)\n * @param params - Optional: `at` (branch, tag, or commit SHA)\n * @returns The raw file content as a string\n */\n async raw(filePath: string, params?: RawFileParams): Promise<string> {\n return this.requestText(\n `${this.basePath}/raw/${filePath}`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n pullRequest(pullRequestId: number): PullRequestResource {\n return new PullRequestResource(this.request, this.projectKey, this.repoSlug, pullRequestId);\n }\n}\n","import type { BitbucketProject } from '../domain/Project';\nimport type { BitbucketRepository, ReposParams } from '../domain/Repository';\nimport type { BitbucketUserPermission, ProjectUsersParams } from '../domain/User';\nimport type { PagedResponse } from '../domain/Pagination';\nimport { RepositoryResource } from './RepositoryResource';\n\n/** @internal */\nexport type RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<T>;\n\n/** @internal */\nexport type RequestTextFn = (\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<string>;\n\n/**\n * Represents a Bitbucket project resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketProject>` so it can be awaited directly\n * to fetch the project info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get project info\n * const project = await bbClient.project('PROJ');\n *\n * // Get repositories with filters\n * const repos = await bbClient.project('PROJ').repos({ limit: 50, name: 'api' });\n *\n * // Navigate into a specific repository\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n *\n * // Get users with access to the project\n * const users = await bbClient.project('PROJ').users({ permission: 'PROJECT_WRITE' });\n * ```\n */\nexport class ProjectResource implements PromiseLike<BitbucketProject> {\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly key: string,\n ) {}\n\n /**\n * Allows the resource to be awaited directly, resolving with the project info.\n * Delegates to {@link ProjectResource.get}.\n */\n then<TResult1 = BitbucketProject, TResult2 = never>(\n onfulfilled?: ((value: BitbucketProject) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the project details.\n *\n * `GET /rest/api/latest/projects/{key}`\n *\n * @returns The project object\n */\n async get(): Promise<BitbucketProject> {\n return this.request<BitbucketProject>(`/projects/${this.key}`);\n }\n\n /**\n * Fetches repositories belonging to this project.\n *\n * `GET /rest/api/latest/projects/{key}/repos`\n *\n * @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`\n * @returns An array of repositories\n */\n async repos(params?: ReposParams): Promise<BitbucketRepository[]> {\n const data = await this.request<PagedResponse<BitbucketRepository>>(\n `/projects/${this.key}/repos`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link RepositoryResource} for a given repository slug, providing\n * access to repository-level data and sub-resources (pull requests, commits, etc.).\n *\n * The returned resource can be awaited directly to fetch repository info,\n * or chained to access nested resources.\n *\n * @param repoSlug - The repository slug (e.g., `'my-repo'`)\n * @returns A chainable repository resource\n *\n * @example\n * ```typescript\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\n repo(repoSlug: string): RepositoryResource {\n return new RepositoryResource(this.request, this.requestText, this.key, repoSlug);\n }\n\n /**\n * Fetches users with explicit permissions on this project.\n *\n * `GET /rest/api/latest/projects/{key}/permissions/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`, `permission`\n * @returns An array of user–permission pairs\n */\n async users(params?: ProjectUsersParams): Promise<BitbucketUserPermission[]> {\n const data = await this.request<PagedResponse<BitbucketUserPermission>>(\n `/projects/${this.key}/permissions/users`,\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n}\n","import type { BitbucketUser } from '../domain/User';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket user resource.\n *\n * Implements `PromiseLike<BitbucketUser>` so it can be awaited directly\n * to fetch user info.\n *\n * @example\n * ```typescript\n * // Await directly to get user info\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class UserResource implements PromiseLike<BitbucketUser> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n slug: string,\n ) {\n this.basePath = `/users/${slug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the user info.\n * Delegates to {@link UserResource.get}.\n */\n then<TResult1 = BitbucketUser, TResult2 = never>(\n onfulfilled?: ((value: BitbucketUser) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the user details.\n *\n * `GET /rest/api/latest/users/{slug}`\n *\n * @returns The user object\n */\n async get(): Promise<BitbucketUser> {\n return this.request<BitbucketUser>(this.basePath);\n }\n}\n","import { Security } from './security/Security';\nimport { ProjectResource, type RequestFn, type RequestTextFn } from './resources/ProjectResource';\nimport { UserResource } from './resources/UserResource';\nimport type { BitbucketProject, ProjectsParams } from './domain/Project';\nimport type { BitbucketUser, UsersParams } from './domain/User';\nimport type { PagedResponse } from './domain/Pagination';\n\n/**\n * Constructor options for {@link BitbucketClient}.\n */\nexport interface BitbucketClientOptions {\n /** The host URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`) */\n apiUrl: string;\n /** The API path to prepend to every request (e.g., `'rest/api/latest'`) */\n apiPath: string;\n /** The username to authenticate with */\n user: string;\n /** The personal access token or password to authenticate with */\n token: string;\n}\n\n/**\n * Main entry point for the Bitbucket Data Center REST API client.\n *\n * @example\n * ```typescript\n * const bbClient = new BitbucketClient({\n * apiUrl: 'https://bitbucket.example.com',\n * apiPath: 'rest/api/latest',\n * user: 'pilmee',\n * token: 'my-token',\n * });\n *\n * const projects = await bbClient.projects({ limit: 50 });\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ name: 'api' });\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * const users = await bbClient.users({ filter: 'john' });\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class BitbucketClient {\n private readonly security: Security;\n private readonly apiPath: string;\n\n /**\n * @param options - Connection and authentication options\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor({ apiUrl, apiPath, user, token }: BitbucketClientOptions) {\n this.security = new Security(apiUrl, user, token);\n this.apiPath = apiPath.replace(/^\\/|\\/$/g, '');\n }\n\n /**\n * Performs an authenticated GET request to the Bitbucket REST API.\n *\n * @param path - API path appended directly to `apiUrl` (e.g., `'/projects'`)\n * @param params - Optional query parameters to append to the URL\n * @throws {Error} If the HTTP response is not OK\n * @internal\n */\n private async request<T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<T> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new Error(`Bitbucket API error: ${response.status} ${response.statusText}`);\n }\n return response.json() as Promise<T>;\n }\n\n private async requestText(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<string> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new Error(`Bitbucket API error: ${response.status} ${response.statusText}`);\n }\n return response.text();\n }\n\n /**\n * Fetches all projects accessible to the authenticated user.\n *\n * `GET /rest/api/latest/projects`\n *\n * @param params - Optional filters: `limit`, `start`, `name`, `permission`\n * @returns An array of projects\n */\n async projects(params?: ProjectsParams): Promise<BitbucketProject[]> {\n const data = await this.request<PagedResponse<BitbucketProject>>(\n '/projects',\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link ProjectResource} for a given project key, providing access\n * to project-level data and sub-resources.\n *\n * The returned resource can be awaited directly to fetch project info,\n * or chained to access nested resources.\n *\n * @param projectKey - The project key (e.g., `'PROJ'`)\n * @returns A chainable project resource\n *\n * @example\n * ```typescript\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ limit: 10 });\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n * ```\n */\n project(projectKey: string): ProjectResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n const requestText: RequestTextFn = (path, params) => this.requestText(path, params);\n return new ProjectResource(request, requestText, projectKey);\n }\n\n /**\n * Fetches all users accessible to the authenticated user.\n *\n * `GET /rest/api/latest/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`\n * @returns An array of users\n */\n async users(params?: UsersParams): Promise<BitbucketUser[]> {\n const data = await this.request<PagedResponse<BitbucketUser>>(\n '/users',\n params as Record<string, string | number | boolean>,\n );\n return data.values;\n }\n\n /**\n * Returns a {@link UserResource} for a given user slug, providing access\n * to user data.\n *\n * The returned resource can be awaited directly to fetch user info.\n *\n * @param slug - The user slug (e.g., `'pilmee'`)\n * @returns A chainable user resource\n *\n * @example\n * ```typescript\n * const user = await bbClient.user('pilmee');\n * ```\n */\n user(slug: string): UserResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n return new UserResource(request, slug);\n }\n}\n\n/**\n * Appends query parameters to a URL string, skipping `undefined` values.\n * @internal\n */\nfunction buildUrl(base: string, params?: Record<string, string | number | boolean>): string {\n if (!params) return base;\n const entries = Object.entries(params).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return base;\n const search = new URLSearchParams(entries.map(([k, v]) => [k, String(v)]));\n return `${base}?${search.toString()}`;\n}\n"],"mappings":";AAIA,SAAS,SAAS,OAAuB;AACvC,MAAI,OAAO,SAAS,aAAa;AAC/B,WAAO,KAAK,KAAK;AAAA,EACnB;AACA,SAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAC7C;AAiBO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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C;AAC1E,SAAO,GAAG,IAAI,IAAI,OAAO,SAAS,CAAC;AACrC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/security/Security.ts","../src/resources/PullRequestResource.ts","../src/resources/RepositoryResource.ts","../src/resources/ProjectResource.ts","../src/errors/BitbucketApiError.ts","../src/resources/UserResource.ts","../src/BitbucketClient.ts"],"sourcesContent":["/**\n * Encodes a string to Base64 in a way that works in both Node.js and browsers.\n * @internal\n */\nfunction toBase64(value: string): string {\n if (typeof btoa !== 'undefined') {\n return btoa(value);\n }\n return Buffer.from(value).toString('base64');\n}\n\n/**\n * Handles Basic Authentication for Bitbucket Data Center REST API requests.\n *\n * @example\n * ```typescript\n * const security = new Security(\n * 'https://bitbucket.example.com',\n * 'my-user',\n * 'my-token'\n * );\n *\n * const headers = security.getHeaders();\n * // { Authorization: 'Basic <base64>', 'Content-Type': 'application/json', Accept: 'application/json' }\n * ```\n */\nexport class Security {\n private readonly apiUrl: string;\n private readonly authorizationHeader: string;\n\n /**\n * Creates a new Security instance with Basic Authentication credentials.\n *\n * @param apiUrl - The base URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`).\n * Must be a valid URL; throws if it cannot be parsed.\n * @param user - The username to authenticate with\n * @param token - The personal access token or password to authenticate with\n *\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor(apiUrl: string, user: string, token: string) {\n if (!URL.canParse(apiUrl)) {\n throw new TypeError(`Invalid apiUrl: \"${apiUrl}\" is not a valid URL`);\n }\n this.apiUrl = apiUrl.replace(/\\/$/, '');\n this.authorizationHeader = `Basic ${toBase64(`${user}:${token}`)}`;\n }\n\n /**\n * Returns the base URL of the Bitbucket Data Center instance, without a trailing slash.\n *\n * @returns The API base URL\n */\n getApiUrl(): string {\n return this.apiUrl;\n }\n\n /**\n * Returns the value of the `Authorization` header for Basic Authentication.\n *\n * @returns The Authorization header value in the format `Basic <base64-encoded-credentials>`\n */\n getAuthorizationHeader(): string {\n return this.authorizationHeader;\n }\n\n /**\n * Returns the full set of HTTP headers required for authenticated API requests.\n *\n * @returns An object containing `Authorization`, `Content-Type`, and `Accept` headers\n */\n getHeaders(): Record<string, string> {\n return {\n Authorization: this.authorizationHeader,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n","import type { BitbucketPullRequest } from '../domain/PullRequest';\nimport type { BitbucketPullRequestActivity, ActivitiesParams } from '../domain/PullRequestActivity';\nimport type { BitbucketPullRequestTask, TasksParams } from '../domain/PullRequestTask';\nimport type { BitbucketCommit } from '../domain/Commit';\nimport type { BitbucketChange, ChangesParams } from '../domain/Change';\nimport type { BitbucketReport, ReportsParams } from '../domain/Report';\nimport type { BitbucketBuildSummaries } from '../domain/BuildSummary';\nimport type { BitbucketIssue } from '../domain/Issue';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket pull request resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketPullRequest>` so it can be awaited directly\n * to fetch the pull request info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get pull request info\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n *\n * // Get activities\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get tasks\n * const tasks = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).tasks();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).commits();\n *\n * // Get changes\n * const changes = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).changes();\n *\n * // Get reports\n * const reports = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).reports();\n *\n * // Get build summaries\n * const builds = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();\n *\n * // Get linked Jira issues\n * const issues = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).issues();\n * ```\n */\nexport class PullRequestResource implements PromiseLike<BitbucketPullRequest> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n projectKey: string,\n repoSlug: string,\n pullRequestId: number,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}/pull-requests/${pullRequestId}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the pull request info.\n * Delegates to {@link PullRequestResource.get}.\n */\n then<TResult1 = BitbucketPullRequest, TResult2 = never>(\n onfulfilled?: ((value: BitbucketPullRequest) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the pull request details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}`\n *\n * @returns The pull request object\n */\n async get(): Promise<BitbucketPullRequest> {\n return this.request<BitbucketPullRequest>(this.basePath);\n }\n\n /**\n * Fetches the activity feed for this pull request.\n *\n * Activities include comments, approvals, reviews, rescopes, merges, and declines.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/activities`\n *\n * @param params - Optional filters: `limit`, `start`, `fromId`, `fromType`\n * @returns An array of pull request activities, ordered from most recent to oldest\n */\n async activities(params?: ActivitiesParams): Promise<PagedResponse<BitbucketPullRequestActivity>> {\n return this.request<PagedResponse<BitbucketPullRequestActivity>>(\n `${this.basePath}/activities`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the tasks (review to-do items) for this pull request.\n *\n * Tasks are created by reviewers on specific comments and can be `OPEN` or `RESOLVED`.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/tasks`\n *\n * @param params - Optional filters: `limit`, `start`\n * @returns An array of pull request tasks\n */\n async tasks(params?: TasksParams): Promise<PagedResponse<BitbucketPullRequestTask>> {\n return this.request<PagedResponse<BitbucketPullRequestTask>>(\n `${this.basePath}/tasks`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the commits included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/commits`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of commits\n */\n async commits(params?: PaginationParams): Promise<PagedResponse<BitbucketCommit>> {\n return this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the file changes included in this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/changes`\n *\n * @param params - Optional filters: `limit`, `start`, `withComments`\n * @returns An array of file changes\n */\n async changes(params?: ChangesParams): Promise<PagedResponse<BitbucketChange>> {\n return this.request<PagedResponse<BitbucketChange>>(\n `${this.basePath}/changes`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the Code Insights reports for this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/reports`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns An array of Code Insights reports\n */\n async reports(params?: ReportsParams): Promise<PagedResponse<BitbucketReport>> {\n return this.request<PagedResponse<BitbucketReport>>(\n `${this.basePath}/reports`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the aggregated build summaries for this pull request.\n *\n * Returns a map of commit hash → build counts per state\n * (`successful`, `failed`, `inProgress`, `cancelled`, `unknown`).\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/build-summaries`\n *\n * @returns A record keyed by commit SHA with aggregated build counts\n */\n async buildSummaries(): Promise<BitbucketBuildSummaries> {\n return this.request<BitbucketBuildSummaries>(`${this.basePath}/build-summaries`);\n }\n\n /**\n * Fetches the Jira issues linked to this pull request.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/issues`\n *\n * @returns An array of linked Jira issues\n */\n async issues(): Promise<BitbucketIssue[]> {\n return this.request<BitbucketIssue[]>(`${this.basePath}/issues`);\n }\n}\n","import type { BitbucketRepository } from '../domain/Repository';\nimport type { BitbucketPullRequest, PullRequestsParams } from '../domain/PullRequest';\nimport type { BitbucketCommit, CommitsParams } from '../domain/Commit';\nimport type { BitbucketBranch, BranchesParams } from '../domain/Branch';\nimport type { BitbucketTag, TagsParams } from '../domain/Tag';\nimport type { BitbucketRepositorySize } from '../domain/RepositorySize';\nimport type { BitbucketLastModifiedEntry, LastModifiedParams } from '../domain/LastModified';\nimport type { RawFileParams } from '../domain/RawFile';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn, RequestTextFn } from './ProjectResource';\nimport { PullRequestResource } from './PullRequestResource';\n\n/**\n * Represents a Bitbucket repository resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketRepository>` so it can be awaited directly\n * to fetch repository info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get repository info\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n *\n * // Get pull requests\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n *\n * // Navigate into a specific pull request\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n *\n * // Get commits\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\nexport class RepositoryResource implements PromiseLike<BitbucketRepository> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly projectKey: string,\n private readonly repoSlug: string,\n ) {\n this.basePath = `/projects/${projectKey}/repos/${repoSlug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the repository info.\n * Delegates to {@link RepositoryResource.get}.\n */\n then<TResult1 = BitbucketRepository, TResult2 = never>(\n onfulfilled?: ((value: BitbucketRepository) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the repository details.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}`\n *\n * @returns The repository object\n */\n async get(): Promise<BitbucketRepository> {\n return this.request<BitbucketRepository>(this.basePath);\n }\n\n /**\n * Fetches pull requests for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests`\n *\n * @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`\n * @returns An array of pull requests\n */\n async pullRequests(params?: PullRequestsParams): Promise<PagedResponse<BitbucketPullRequest>> {\n return this.request<PagedResponse<BitbucketPullRequest>>(\n `${this.basePath}/pull-requests`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches commits for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/commits`\n *\n * @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`\n * @returns An array of commits\n */\n async commits(params?: CommitsParams): Promise<PagedResponse<BitbucketCommit>> {\n return this.request<PagedResponse<BitbucketCommit>>(\n `${this.basePath}/commits`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the files last modified in this repository along with the commit that last touched each.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/last-modified`\n *\n * @param params - Optional filters: `limit`, `start`, `at`\n * @returns An array of last-modified entries\n */\n async lastModified(params?: LastModifiedParams): Promise<PagedResponse<BitbucketLastModifiedEntry>> {\n return this.request<PagedResponse<BitbucketLastModifiedEntry>>(\n `${this.basePath}/last-modified`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the size of this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/sizes`\n *\n * @returns The repository size object\n */\n async size(): Promise<BitbucketRepositorySize> {\n return this.request<BitbucketRepositorySize>(`${this.basePath}/sizes`);\n }\n\n /**\n * Fetches branches for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/branches`\n *\n * @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`, `details`, `base`, `boostMatches`\n * @returns An array of branches\n */\n async branches(params?: BranchesParams): Promise<PagedResponse<BitbucketBranch>> {\n return this.request<PagedResponse<BitbucketBranch>>(\n `${this.basePath}/branches`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches the forks of this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/forks`\n *\n * @param params - Optional pagination: `limit`, `start`\n * @returns A paged response of forked repositories\n */\n async forks(params?: PaginationParams): Promise<PagedResponse<BitbucketRepository>> {\n return this.request<PagedResponse<BitbucketRepository>>(\n `${this.basePath}/forks`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Fetches tags for this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/tags`\n *\n * @param params - Optional filters: `limit`, `start`, `filterText`, `orderBy`\n * @returns A paged response of tags\n */\n async tags(params?: TagsParams): Promise<PagedResponse<BitbucketTag>> {\n return this.request<PagedResponse<BitbucketTag>>(\n `${this.basePath}/tags`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link PullRequestResource} for a given pull request ID, providing\n * access to pull request data and sub-resources (activities, etc.).\n *\n * The returned resource can be awaited directly to fetch pull request info,\n * or chained to access nested resources.\n *\n * @param pullRequestId - The numeric pull request ID\n * @returns A chainable pull request resource\n *\n * @example\n * ```typescript\n * const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);\n * const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();\n * ```\n */\n /**\n * Fetches the raw content of a file in this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}`\n *\n * @param filePath - Path to the file (e.g., `'src/index.ts'`)\n * @param params - Optional: `at` (branch, tag, or commit SHA)\n * @returns The raw file content as a string\n */\n async raw(filePath: string, params?: RawFileParams): Promise<string> {\n return this.requestText(\n `${this.basePath}/raw/${filePath}`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n pullRequest(pullRequestId: number): PullRequestResource {\n return new PullRequestResource(this.request, this.projectKey, this.repoSlug, pullRequestId);\n }\n}\n","import type { BitbucketProject } from '../domain/Project';\nimport type { BitbucketRepository, ReposParams } from '../domain/Repository';\nimport type { BitbucketUserPermission, ProjectUsersParams } from '../domain/User';\nimport type { PagedResponse } from '../domain/Pagination';\nimport { RepositoryResource } from './RepositoryResource';\n\n/** @internal */\nexport type RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<T>;\n\n/** @internal */\nexport type RequestTextFn = (\n path: string,\n params?: Record<string, string | number | boolean>,\n) => Promise<string>;\n\n/**\n * Represents a Bitbucket project resource with chainable async methods.\n *\n * Implements `PromiseLike<BitbucketProject>` so it can be awaited directly\n * to fetch the project info, while also exposing sub-resource methods.\n *\n * @example\n * ```typescript\n * // Await directly to get project info\n * const project = await bbClient.project('PROJ');\n *\n * // Get repositories with filters\n * const repos = await bbClient.project('PROJ').repos({ limit: 50, name: 'api' });\n *\n * // Navigate into a specific repository\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n *\n * // Get users with access to the project\n * const users = await bbClient.project('PROJ').users({ permission: 'PROJECT_WRITE' });\n * ```\n */\nexport class ProjectResource implements PromiseLike<BitbucketProject> {\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n private readonly requestText: RequestTextFn,\n private readonly key: string,\n ) {}\n\n /**\n * Allows the resource to be awaited directly, resolving with the project info.\n * Delegates to {@link ProjectResource.get}.\n */\n then<TResult1 = BitbucketProject, TResult2 = never>(\n onfulfilled?: ((value: BitbucketProject) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the project details.\n *\n * `GET /rest/api/latest/projects/{key}`\n *\n * @returns The project object\n */\n async get(): Promise<BitbucketProject> {\n return this.request<BitbucketProject>(`/projects/${this.key}`);\n }\n\n /**\n * Fetches repositories belonging to this project.\n *\n * `GET /rest/api/latest/projects/{key}/repos`\n *\n * @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`\n * @returns An array of repositories\n */\n async repos(params?: ReposParams): Promise<PagedResponse<BitbucketRepository>> {\n return this.request<PagedResponse<BitbucketRepository>>(\n `/projects/${this.key}/repos`,\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link RepositoryResource} for a given repository slug, providing\n * access to repository-level data and sub-resources (pull requests, commits, etc.).\n *\n * The returned resource can be awaited directly to fetch repository info,\n * or chained to access nested resources.\n *\n * @param repoSlug - The repository slug (e.g., `'my-repo'`)\n * @returns A chainable repository resource\n *\n * @example\n * ```typescript\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * ```\n */\n repo(repoSlug: string): RepositoryResource {\n return new RepositoryResource(this.request, this.requestText, this.key, repoSlug);\n }\n\n /**\n * Fetches users with explicit permissions on this project.\n *\n * `GET /rest/api/latest/projects/{key}/permissions/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`, `permission`\n * @returns An array of user–permission pairs\n */\n async users(params?: ProjectUsersParams): Promise<PagedResponse<BitbucketUserPermission>> {\n return this.request<PagedResponse<BitbucketUserPermission>>(\n `/projects/${this.key}/permissions/users`,\n params as Record<string, string | number | boolean>,\n );\n }\n}\n","/**\n * Thrown when the Bitbucket Data Center API returns a non-2xx response.\n *\n * @example\n * ```typescript\n * import { BitbucketApiError } from 'bitbucket-datacenter-api-client';\n *\n * try {\n * await bb.project('NONEXISTENT');\n * } catch (err) {\n * if (err instanceof BitbucketApiError) {\n * console.log(err.status); // 404\n * console.log(err.statusText); // 'Not Found'\n * console.log(err.message); // 'Bitbucket API error: 404 Not Found'\n * }\n * }\n * ```\n */\nexport class BitbucketApiError extends Error {\n /** HTTP status code (e.g. `404`, `401`, `403`) */\n readonly status: number;\n /** HTTP status text (e.g. `'Not Found'`, `'Unauthorized'`) */\n readonly statusText: string;\n\n constructor(status: number, statusText: string) {\n super(`Bitbucket API error: ${status} ${statusText}`);\n this.name = 'BitbucketApiError';\n this.status = status;\n this.statusText = statusText;\n }\n}\n","import type { BitbucketUser } from '../domain/User';\nimport type { RequestFn } from './ProjectResource';\n\n/**\n * Represents a Bitbucket user resource.\n *\n * Implements `PromiseLike<BitbucketUser>` so it can be awaited directly\n * to fetch user info.\n *\n * @example\n * ```typescript\n * // Await directly to get user info\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class UserResource implements PromiseLike<BitbucketUser> {\n private readonly basePath: string;\n\n /** @internal */\n constructor(\n private readonly request: RequestFn,\n slug: string,\n ) {\n this.basePath = `/users/${slug}`;\n }\n\n /**\n * Allows the resource to be awaited directly, resolving with the user info.\n * Delegates to {@link UserResource.get}.\n */\n then<TResult1 = BitbucketUser, TResult2 = never>(\n onfulfilled?: ((value: BitbucketUser) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.get().then(onfulfilled, onrejected);\n }\n\n /**\n * Fetches the user details.\n *\n * `GET /rest/api/latest/users/{slug}`\n *\n * @returns The user object\n */\n async get(): Promise<BitbucketUser> {\n return this.request<BitbucketUser>(this.basePath);\n }\n}\n","import { Security } from './security/Security';\nimport { ProjectResource, type RequestFn, type RequestTextFn } from './resources/ProjectResource';\nimport { BitbucketApiError } from './errors/BitbucketApiError';\nimport { UserResource } from './resources/UserResource';\nimport type { BitbucketProject, ProjectsParams } from './domain/Project';\nimport type { BitbucketUser, UsersParams } from './domain/User';\nimport type { PagedResponse } from './domain/Pagination';\n\n/**\n * Constructor options for {@link BitbucketClient}.\n */\nexport interface BitbucketClientOptions {\n /** The host URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`) */\n apiUrl: string;\n /** The API path to prepend to every request (e.g., `'rest/api/latest'`) */\n apiPath: string;\n /** The username to authenticate with */\n user: string;\n /** The personal access token or password to authenticate with */\n token: string;\n}\n\n/**\n * Main entry point for the Bitbucket Data Center REST API client.\n *\n * @example\n * ```typescript\n * const bbClient = new BitbucketClient({\n * apiUrl: 'https://bitbucket.example.com',\n * apiPath: 'rest/api/latest',\n * user: 'pilmee',\n * token: 'my-token',\n * });\n *\n * const projects = await bbClient.projects({ limit: 50 });\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ name: 'api' });\n * const repo = await bbClient.project('PROJ').repo('my-repo');\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });\n * const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });\n * const users = await bbClient.users({ filter: 'john' });\n * const user = await bbClient.user('pilmee');\n * ```\n */\nexport class BitbucketClient {\n private readonly security: Security;\n private readonly apiPath: string;\n\n /**\n * @param options - Connection and authentication options\n * @throws {TypeError} If `apiUrl` is not a valid URL\n */\n constructor({ apiUrl, apiPath, user, token }: BitbucketClientOptions) {\n this.security = new Security(apiUrl, user, token);\n this.apiPath = apiPath.replace(/^\\/|\\/$/g, '');\n }\n\n /**\n * Performs an authenticated GET request to the Bitbucket REST API.\n *\n * @param path - API path appended directly to `apiUrl` (e.g., `'/projects'`)\n * @param params - Optional query parameters to append to the URL\n * @throws {Error} If the HTTP response is not OK\n * @internal\n */\n private async request<T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<T> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new BitbucketApiError(response.status, response.statusText);\n }\n return response.json() as Promise<T>;\n }\n\n private async requestText(\n path: string,\n params?: Record<string, string | number | boolean>,\n ): Promise<string> {\n const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const url = buildUrl(base, params);\n const response = await fetch(url, { headers: this.security.getHeaders() });\n if (!response.ok) {\n throw new BitbucketApiError(response.status, response.statusText);\n }\n return response.text();\n }\n\n /**\n * Fetches all projects accessible to the authenticated user.\n *\n * `GET /rest/api/latest/projects`\n *\n * @param params - Optional filters: `limit`, `start`, `name`, `permission`\n * @returns An array of projects\n */\n async projects(params?: ProjectsParams): Promise<PagedResponse<BitbucketProject>> {\n return this.request<PagedResponse<BitbucketProject>>(\n '/projects',\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link ProjectResource} for a given project key, providing access\n * to project-level data and sub-resources.\n *\n * The returned resource can be awaited directly to fetch project info,\n * or chained to access nested resources.\n *\n * @param projectKey - The project key (e.g., `'PROJ'`)\n * @returns A chainable project resource\n *\n * @example\n * ```typescript\n * const project = await bbClient.project('PROJ');\n * const repos = await bbClient.project('PROJ').repos({ limit: 10 });\n * const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();\n * ```\n */\n project(projectKey: string): ProjectResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n const requestText: RequestTextFn = (path, params) => this.requestText(path, params);\n return new ProjectResource(request, requestText, projectKey);\n }\n\n /**\n * Fetches all users accessible to the authenticated user.\n *\n * `GET /rest/api/latest/users`\n *\n * @param params - Optional filters: `limit`, `start`, `filter`\n * @returns An array of users\n */\n async users(params?: UsersParams): Promise<PagedResponse<BitbucketUser>> {\n return this.request<PagedResponse<BitbucketUser>>(\n '/users',\n params as Record<string, string | number | boolean>,\n );\n }\n\n /**\n * Returns a {@link UserResource} for a given user slug, providing access\n * to user data.\n *\n * The returned resource can be awaited directly to fetch user info.\n *\n * @param slug - The user slug (e.g., `'pilmee'`)\n * @returns A chainable user resource\n *\n * @example\n * ```typescript\n * const user = await bbClient.user('pilmee');\n * ```\n */\n user(slug: string): UserResource {\n const request: RequestFn = <T>(\n path: string,\n params?: Record<string, string | number | boolean>,\n ) => this.request<T>(path, params);\n return new UserResource(request, slug);\n }\n}\n\n/**\n * Appends query parameters to a URL string, skipping `undefined` values.\n * @internal\n */\nfunction buildUrl(base: string, params?: Record<string, string | number | boolean>): string {\n if (!params) return base;\n const entries = Object.entries(params).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return base;\n const search = new URLSearchParams(entries.map(([k, v]) => [k, String(v)]));\n return `${base}?${search.toString()}`;\n}\n"],"mappings":";AAIA,SAAS,SAAS,OAAuB;AACvC,MAAI,OAAO,SAAS,aAAa;AAC/B,WAAO,KAAK,KAAK;AAAA,EACnB;AACA,SAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAC7C;AAiBO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcpB,YAAY,QAAgB,MAAc,OAAe;AACvD,QAAI,CAAC,IAAI,SAAS,MAAM,GAAG;AACzB,YAAM,IAAI,UAAU,oBAAoB,MAAM,sBAAsB;AAAA,IACtE;AACA,SAAK,SAAS,OAAO,QAAQ,OAAO,EAAE;AACtC,SAAK,sBAAsB,SAAS,SAAS,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,yBAAiC;AAC/B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAqC;AACnC,WAAO;AAAA,MACL,eAAe,KAAK;AAAA,MACpB,gBAAgB;AAAA,MAChB,QAAQ;AAAA,IACV;AAAA,EACF;AACF;;;AClCO,IAAM,sBAAN,MAAuE;AAAA;AAAA,EAI5E,YACmB,SACjB,YACA,UACA,eACA;AAJiB;AAKjB,SAAK,WAAW,aAAa,UAAU,UAAU,QAAQ,k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MAAM,MAAM,QAA6D;AACvE,WAAO,KAAK;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,KAAK,MAA4B;AAC/B,UAAM,UAAqB,CACzB,MACA,WACG,KAAK,QAAW,MAAM,MAAM;AACjC,WAAO,IAAI,aAAa,SAAS,IAAI;AAAA,EACvC;AACF;AAMA,SAAS,SAAS,MAAc,QAA4D;AAC1F,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,UAAU,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS;AACxE,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,SAAS,IAAI,gBAAgB,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1E,SAAO,GAAG,IAAI,IAAI,OAAO,SAAS,CAAC;AACrC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bitbucket-datacenter-api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "TypeScript client for Bitbucket Data Center REST API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"rest"
|
|
30
30
|
],
|
|
31
31
|
"license": "MIT",
|
|
32
|
+
"homepage": "https://eljijuna.github.io/BitbucketDataCenterApiClient",
|
|
32
33
|
"repository": {
|
|
33
34
|
"type": "git",
|
|
34
35
|
"url": "https://github.com/ElJijuna/BitbucketDataCenterApiClient.git"
|