bitbucket-datacenter-api-client 1.5.0 → 1.6.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 CHANGED
@@ -836,11 +836,12 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
836
836
  declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
837
837
  private readonly request;
838
838
  private readonly requestText;
839
+ private readonly requestBody;
839
840
  private readonly projectKey;
840
841
  private readonly repoSlug;
841
842
  private readonly basePath;
842
843
  /** @internal */
843
- constructor(request: RequestFn, requestText: RequestTextFn, projectKey: string, repoSlug: string);
844
+ constructor(request: RequestFn, requestText: RequestTextFn, requestBody: RequestBodyFn, projectKey: string, repoSlug: string);
844
845
  /**
845
846
  * Allows the resource to be awaited directly, resolving with the repository info.
846
847
  * Delegates to {@link RepositoryResource.get}.
@@ -907,6 +908,15 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
907
908
  * @returns A paged response of forked repositories
908
909
  */
909
910
  forks(params?: PaginationParams): Promise<PagedResponse<BitbucketRepository>>;
911
+ /**
912
+ * Fetches tags associated with a list of commits.
913
+ *
914
+ * `POST /rest/api/latest/projects/{key}/repos/{slug}/tags`
915
+ *
916
+ * @param commits - Array of commit SHAs to look up tags for
917
+ * @returns A paged response of tags
918
+ */
919
+ tagsByCommits(commits: string[]): Promise<PagedResponse<BitbucketTag>>;
910
920
  /**
911
921
  * Fetches tags for this repository.
912
922
  *
@@ -958,6 +968,8 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
958
968
  type RequestFn = <T>(path: string, params?: Record<string, string | number | boolean>) => Promise<T>;
959
969
  /** @internal */
960
970
  type RequestTextFn = (path: string, params?: Record<string, string | number | boolean>) => Promise<string>;
971
+ /** @internal */
972
+ type RequestBodyFn = <T>(path: string, body: unknown) => Promise<T>;
961
973
  /**
962
974
  * Represents a Bitbucket project resource with chainable async methods.
963
975
  *
@@ -982,9 +994,10 @@ type RequestTextFn = (path: string, params?: Record<string, string | number | bo
982
994
  declare class ProjectResource implements PromiseLike<BitbucketProject> {
983
995
  private readonly request;
984
996
  private readonly requestText;
997
+ private readonly requestBody;
985
998
  private readonly key;
986
999
  /** @internal */
987
- constructor(request: RequestFn, requestText: RequestTextFn, key: string);
1000
+ constructor(request: RequestFn, requestText: RequestTextFn, requestBody: RequestBodyFn, key: string);
988
1001
  /**
989
1002
  * Allows the resource to be awaited directly, resolving with the project info.
990
1003
  * Delegates to {@link ProjectResource.get}.
@@ -1129,6 +1142,7 @@ declare class BitbucketClient {
1129
1142
  * @internal
1130
1143
  */
1131
1144
  private request;
1145
+ private requestPost;
1132
1146
  private requestText;
1133
1147
  /**
1134
1148
  * Fetches all projects accessible to the authenticated user.
package/dist/index.d.ts CHANGED
@@ -836,11 +836,12 @@ declare class PullRequestResource implements PromiseLike<BitbucketPullRequest> {
836
836
  declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
837
837
  private readonly request;
838
838
  private readonly requestText;
839
+ private readonly requestBody;
839
840
  private readonly projectKey;
840
841
  private readonly repoSlug;
841
842
  private readonly basePath;
842
843
  /** @internal */
843
- constructor(request: RequestFn, requestText: RequestTextFn, projectKey: string, repoSlug: string);
844
+ constructor(request: RequestFn, requestText: RequestTextFn, requestBody: RequestBodyFn, projectKey: string, repoSlug: string);
844
845
  /**
845
846
  * Allows the resource to be awaited directly, resolving with the repository info.
846
847
  * Delegates to {@link RepositoryResource.get}.
@@ -907,6 +908,15 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
907
908
  * @returns A paged response of forked repositories
908
909
  */
909
910
  forks(params?: PaginationParams): Promise<PagedResponse<BitbucketRepository>>;
911
+ /**
912
+ * Fetches tags associated with a list of commits.
913
+ *
914
+ * `POST /rest/api/latest/projects/{key}/repos/{slug}/tags`
915
+ *
916
+ * @param commits - Array of commit SHAs to look up tags for
917
+ * @returns A paged response of tags
918
+ */
919
+ tagsByCommits(commits: string[]): Promise<PagedResponse<BitbucketTag>>;
910
920
  /**
911
921
  * Fetches tags for this repository.
912
922
  *
@@ -958,6 +968,8 @@ declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
958
968
  type RequestFn = <T>(path: string, params?: Record<string, string | number | boolean>) => Promise<T>;
959
969
  /** @internal */
960
970
  type RequestTextFn = (path: string, params?: Record<string, string | number | boolean>) => Promise<string>;
971
+ /** @internal */
972
+ type RequestBodyFn = <T>(path: string, body: unknown) => Promise<T>;
961
973
  /**
962
974
  * Represents a Bitbucket project resource with chainable async methods.
963
975
  *
@@ -982,9 +994,10 @@ type RequestTextFn = (path: string, params?: Record<string, string | number | bo
982
994
  declare class ProjectResource implements PromiseLike<BitbucketProject> {
983
995
  private readonly request;
984
996
  private readonly requestText;
997
+ private readonly requestBody;
985
998
  private readonly key;
986
999
  /** @internal */
987
- constructor(request: RequestFn, requestText: RequestTextFn, key: string);
1000
+ constructor(request: RequestFn, requestText: RequestTextFn, requestBody: RequestBodyFn, key: string);
988
1001
  /**
989
1002
  * Allows the resource to be awaited directly, resolving with the project info.
990
1003
  * Delegates to {@link ProjectResource.get}.
@@ -1129,6 +1142,7 @@ declare class BitbucketClient {
1129
1142
  * @internal
1130
1143
  */
1131
1144
  private request;
1145
+ private requestPost;
1132
1146
  private requestText;
1133
1147
  /**
1134
1148
  * Fetches all projects accessible to the authenticated user.
package/dist/index.js CHANGED
@@ -211,9 +211,10 @@ var PullRequestResource = class {
211
211
  // src/resources/RepositoryResource.ts
212
212
  var RepositoryResource = class {
213
213
  /** @internal */
214
- constructor(request, requestText, projectKey, repoSlug) {
214
+ constructor(request, requestText, requestBody, projectKey, repoSlug) {
215
215
  this.request = request;
216
216
  this.requestText = requestText;
217
+ this.requestBody = requestBody;
217
218
  this.projectKey = projectKey;
218
219
  this.repoSlug = repoSlug;
219
220
  this.basePath = `/projects/${projectKey}/repos/${repoSlug}`;
@@ -315,6 +316,17 @@ var RepositoryResource = class {
315
316
  params
316
317
  );
317
318
  }
319
+ /**
320
+ * Fetches tags associated with a list of commits.
321
+ *
322
+ * `POST /rest/api/latest/projects/{key}/repos/{slug}/tags`
323
+ *
324
+ * @param commits - Array of commit SHAs to look up tags for
325
+ * @returns A paged response of tags
326
+ */
327
+ async tagsByCommits(commits) {
328
+ return this.requestBody(`${this.basePath}/tags`, commits);
329
+ }
318
330
  /**
319
331
  * Fetches tags for this repository.
320
332
  *
@@ -382,9 +394,10 @@ var RepositoryResource = class {
382
394
  // src/resources/ProjectResource.ts
383
395
  var ProjectResource = class {
384
396
  /** @internal */
385
- constructor(request, requestText, key) {
397
+ constructor(request, requestText, requestBody, key) {
386
398
  this.request = request;
387
399
  this.requestText = requestText;
400
+ this.requestBody = requestBody;
388
401
  this.key = key;
389
402
  }
390
403
  /**
@@ -436,7 +449,7 @@ var ProjectResource = class {
436
449
  * ```
437
450
  */
438
451
  repo(repoSlug) {
439
- return new RepositoryResource(this.request, this.requestText, this.key, repoSlug);
452
+ return new RepositoryResource(this.request, this.requestText, this.requestBody, this.key, repoSlug);
440
453
  }
441
454
  /**
442
455
  * Fetches users with explicit permissions on this project.
@@ -531,6 +544,18 @@ var BitbucketClient = class {
531
544
  }
532
545
  return response.json();
533
546
  }
547
+ async requestPost(path, body) {
548
+ const url = `${this.security.getApiUrl()}/${this.apiPath}${path}`;
549
+ const response = await fetch(url, {
550
+ method: "POST",
551
+ headers: this.security.getHeaders(),
552
+ body: JSON.stringify(body)
553
+ });
554
+ if (!response.ok) {
555
+ throw new BitbucketApiError(response.status, response.statusText);
556
+ }
557
+ return response.json();
558
+ }
534
559
  async requestText(path, params) {
535
560
  const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;
536
561
  const url = buildUrl(base, params);
@@ -574,7 +599,8 @@ var BitbucketClient = class {
574
599
  project(projectKey) {
575
600
  const request = (path, params) => this.request(path, params);
576
601
  const requestText = (path, params) => this.requestText(path, params);
577
- return new ProjectResource(request, requestText, projectKey);
602
+ const requestBody = (path, body) => this.requestPost(path, body);
603
+ return new ProjectResource(request, requestText, requestBody, projectKey);
578
604
  }
579
605
  /**
580
606
  * Fetches all users accessible to the authenticated user.
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/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 {\n BitbucketWebhook,\n BitbucketWebhookStatistics,\n BitbucketWebhookDelivery,\n BitbucketWebhookRequest,\n BitbucketWebhookResult,\n BitbucketWebhookEventScope,\n BitbucketWebhookCounts,\n WebhooksParams,\n WebhookEvent,\n WebhookScopeType,\n} from './domain/Webhook';\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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\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 webhooks configured on this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/webhooks/search`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `${this.basePath}/webhooks/search`,\n params as Record<string, string | number | boolean>,\n );\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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\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 * Fetches webhooks configured on this project.\n *\n * `GET /rest/api/latest/projects/{key}/webhooks`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `/projects/${this.key}/webhooks`,\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;A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;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 {\n BitbucketWebhook,\n BitbucketWebhookStatistics,\n BitbucketWebhookDelivery,\n BitbucketWebhookRequest,\n BitbucketWebhookResult,\n BitbucketWebhookEventScope,\n BitbucketWebhookCounts,\n WebhooksParams,\n WebhookEvent,\n WebhookScopeType,\n} from './domain/Webhook';\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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn, RequestTextFn, RequestBodyFn } 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 requestBody: RequestBodyFn,\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 associated with a list of commits.\n *\n * `POST /rest/api/latest/projects/{key}/repos/{slug}/tags`\n *\n * @param commits - Array of commit SHAs to look up tags for\n * @returns A paged response of tags\n */\n async tagsByCommits(commits: string[]): Promise<PagedResponse<BitbucketTag>> {\n return this.requestBody<PagedResponse<BitbucketTag>>(`${this.basePath}/tags`, commits);\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 webhooks configured on this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/webhooks/search`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `${this.basePath}/webhooks/search`,\n params as Record<string, string | number | boolean>,\n );\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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\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/** @internal */\nexport type RequestBodyFn = <T>(path: string, body: unknown) => Promise<T>;\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 requestBody: RequestBodyFn,\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.requestBody, 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 * Fetches webhooks configured on this project.\n *\n * `GET /rest/api/latest/projects/{key}/webhooks`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `/projects/${this.key}/webhooks`,\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, type RequestBodyFn } 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 requestPost<T>(path: string, body: unknown): Promise<T> {\n const url = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const response = await fetch(url, {\n method: 'POST',\n headers: this.security.getHeaders(),\n body: JSON.stringify(body),\n });\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 const requestBody: RequestBodyFn = <T>(path: string, body: unknown) => this.requestPost<T>(path, body);\n return new ProjectResource(request, requestText, requestBody, 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,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcpB,YAAY,QAAgB,MAAc,OAAe;AACvD,QAAI,CAAC,IAAI,SAAS,MAAM,G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A;AAAA;AAAA;AAAA,EAmBA,QAAQ,YAAqC;AAC3C,UAAM,UAAqB,CACzB,MACA,WACG,KAAK,QAAW,MAAM,MAAM;AACjC,UAAM,cAA6B,CAAC,MAAM,WAAW,KAAK,YAAY,MAAM,MAAM;AAClF,UAAM,cAA6B,CAAI,MAAc,SAAkB,KAAK,YAAe,MAAM,IAAI;AACrG,WAAO,IAAI,gBAAgB,SAAS,aAAa,aAAa,UAAU;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,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/dist/index.mjs CHANGED
@@ -179,9 +179,10 @@ var PullRequestResource = class {
179
179
  // src/resources/RepositoryResource.ts
180
180
  var RepositoryResource = class {
181
181
  /** @internal */
182
- constructor(request, requestText, projectKey, repoSlug) {
182
+ constructor(request, requestText, requestBody, projectKey, repoSlug) {
183
183
  this.request = request;
184
184
  this.requestText = requestText;
185
+ this.requestBody = requestBody;
185
186
  this.projectKey = projectKey;
186
187
  this.repoSlug = repoSlug;
187
188
  this.basePath = `/projects/${projectKey}/repos/${repoSlug}`;
@@ -283,6 +284,17 @@ var RepositoryResource = class {
283
284
  params
284
285
  );
285
286
  }
287
+ /**
288
+ * Fetches tags associated with a list of commits.
289
+ *
290
+ * `POST /rest/api/latest/projects/{key}/repos/{slug}/tags`
291
+ *
292
+ * @param commits - Array of commit SHAs to look up tags for
293
+ * @returns A paged response of tags
294
+ */
295
+ async tagsByCommits(commits) {
296
+ return this.requestBody(`${this.basePath}/tags`, commits);
297
+ }
286
298
  /**
287
299
  * Fetches tags for this repository.
288
300
  *
@@ -350,9 +362,10 @@ var RepositoryResource = class {
350
362
  // src/resources/ProjectResource.ts
351
363
  var ProjectResource = class {
352
364
  /** @internal */
353
- constructor(request, requestText, key) {
365
+ constructor(request, requestText, requestBody, key) {
354
366
  this.request = request;
355
367
  this.requestText = requestText;
368
+ this.requestBody = requestBody;
356
369
  this.key = key;
357
370
  }
358
371
  /**
@@ -404,7 +417,7 @@ var ProjectResource = class {
404
417
  * ```
405
418
  */
406
419
  repo(repoSlug) {
407
- return new RepositoryResource(this.request, this.requestText, this.key, repoSlug);
420
+ return new RepositoryResource(this.request, this.requestText, this.requestBody, this.key, repoSlug);
408
421
  }
409
422
  /**
410
423
  * Fetches users with explicit permissions on this project.
@@ -499,6 +512,18 @@ var BitbucketClient = class {
499
512
  }
500
513
  return response.json();
501
514
  }
515
+ async requestPost(path, body) {
516
+ const url = `${this.security.getApiUrl()}/${this.apiPath}${path}`;
517
+ const response = await fetch(url, {
518
+ method: "POST",
519
+ headers: this.security.getHeaders(),
520
+ body: JSON.stringify(body)
521
+ });
522
+ if (!response.ok) {
523
+ throw new BitbucketApiError(response.status, response.statusText);
524
+ }
525
+ return response.json();
526
+ }
502
527
  async requestText(path, params) {
503
528
  const base = `${this.security.getApiUrl()}/${this.apiPath}${path}`;
504
529
  const url = buildUrl(base, params);
@@ -542,7 +567,8 @@ var BitbucketClient = class {
542
567
  project(projectKey) {
543
568
  const request = (path, params) => this.request(path, params);
544
569
  const requestText = (path, params) => this.requestText(path, params);
545
- return new ProjectResource(request, requestText, projectKey);
570
+ const requestBody = (path, body) => this.requestPost(path, body);
571
+ return new ProjectResource(request, requestText, requestBody, projectKey);
546
572
  }
547
573
  /**
548
574
  * Fetches all users accessible to the authenticated user.
@@ -1 +1 @@
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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\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 webhooks configured on this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/webhooks/search`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `${this.basePath}/webhooks/search`,\n params as Record<string, string | number | boolean>,\n );\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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\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 * Fetches webhooks configured on this project.\n *\n * `GET /rest/api/latest/projects/{key}/webhooks`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `/projects/${this.key}/webhooks`,\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,E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AA;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/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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\nimport type { PagedResponse, PaginationParams } from '../domain/Pagination';\nimport type { RequestFn, RequestTextFn, RequestBodyFn } 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 requestBody: RequestBodyFn,\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 associated with a list of commits.\n *\n * `POST /rest/api/latest/projects/{key}/repos/{slug}/tags`\n *\n * @param commits - Array of commit SHAs to look up tags for\n * @returns A paged response of tags\n */\n async tagsByCommits(commits: string[]): Promise<PagedResponse<BitbucketTag>> {\n return this.requestBody<PagedResponse<BitbucketTag>>(`${this.basePath}/tags`, commits);\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 webhooks configured on this repository.\n *\n * `GET /rest/api/latest/projects/{key}/repos/{slug}/webhooks/search`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `${this.basePath}/webhooks/search`,\n params as Record<string, string | number | boolean>,\n );\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 { BitbucketWebhook, WebhooksParams } from '../domain/Webhook';\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/** @internal */\nexport type RequestBodyFn = <T>(path: string, body: unknown) => Promise<T>;\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 requestBody: RequestBodyFn,\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.requestBody, 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 * Fetches webhooks configured on this project.\n *\n * `GET /rest/api/latest/projects/{key}/webhooks`\n *\n * @param params - Optional filters: `limit`, `start`, `event`\n * @returns A paged response of webhooks\n */\n async webhooks(params?: WebhooksParams): Promise<PagedResponse<BitbucketWebhook>> {\n return this.request<PagedResponse<BitbucketWebhook>>(\n `/projects/${this.key}/webhooks`,\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, type RequestBodyFn } 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 requestPost<T>(path: string, body: unknown): Promise<T> {\n const url = `${this.security.getApiUrl()}/${this.apiPath}${path}`;\n const response = await fetch(url, {\n method: 'POST',\n headers: this.security.getHeaders(),\n body: JSON.stringify(body),\n });\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 const requestBody: RequestBodyFn = <T>(path: string, body: unknown) => this.requestPost<T>(path, body);\n return new ProjectResource(request, requestText, requestBody, 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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A6B,CAAC,MAAM,WAAW,KAAK,YAAY,MAAM,MAAM;AAClF,UAAM,cAA6B,CAAI,MAAc,SAAkB,KAAK,YAAe,MAAM,IAAI;AACrG,WAAO,IAAI,gBAAgB,SAAS,aAAa,aAAa,UAAU;AAAA,EAC1E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,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.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "TypeScript client for Bitbucket Data Center REST API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",