bitbucket-datacenter-api-client 0.1.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/LICENSE +21 -0
- package/dist/index.d.mts +455 -0
- package/dist/index.d.ts +455 -0
- package/dist/index.js +272 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +249 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 el_jijuna
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common pagination and filtering parameters accepted by Bitbucket Data Center list endpoints.
|
|
3
|
+
*/
|
|
4
|
+
interface PaginationParams {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum number of results to return per page.
|
|
7
|
+
* Bitbucket default is `25`, maximum is `1000`.
|
|
8
|
+
*/
|
|
9
|
+
limit?: number;
|
|
10
|
+
/**
|
|
11
|
+
* 0-based index of the first result to return.
|
|
12
|
+
* Use `nextPageStart` from the previous response to paginate forward.
|
|
13
|
+
*/
|
|
14
|
+
start?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper returned by Bitbucket paginated list endpoints.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
interface PagedResponse<T> {
|
|
21
|
+
values: T[];
|
|
22
|
+
size: number;
|
|
23
|
+
limit: number;
|
|
24
|
+
isLastPage: boolean;
|
|
25
|
+
start: number;
|
|
26
|
+
nextPageStart?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Represents a Bitbucket Data Center project.
|
|
31
|
+
*/
|
|
32
|
+
interface BitbucketProject {
|
|
33
|
+
key: string;
|
|
34
|
+
id: number;
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
public: boolean;
|
|
38
|
+
type: 'NORMAL' | 'PERSONAL';
|
|
39
|
+
links: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Query parameters accepted by `GET /rest/api/latest/projects`.
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-project/#api-api-latest-projects-get}
|
|
45
|
+
*/
|
|
46
|
+
interface ProjectsParams extends PaginationParams {
|
|
47
|
+
/** Filter by project name (case-insensitive prefix match) */
|
|
48
|
+
name?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Filter by the permission the authenticated user has on the project.
|
|
51
|
+
* e.g. `'PROJECT_READ'`, `'PROJECT_WRITE'`, `'PROJECT_ADMIN'`
|
|
52
|
+
*/
|
|
53
|
+
permission?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Represents a Bitbucket Data Center repository.
|
|
58
|
+
*/
|
|
59
|
+
interface BitbucketRepository {
|
|
60
|
+
slug: string;
|
|
61
|
+
id: number;
|
|
62
|
+
name: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
state: string;
|
|
65
|
+
statusMessage: string;
|
|
66
|
+
forkable: boolean;
|
|
67
|
+
project: BitbucketProject;
|
|
68
|
+
public: boolean;
|
|
69
|
+
links: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Query parameters accepted by `GET /rest/api/latest/projects/{key}/repos`.
|
|
73
|
+
*
|
|
74
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-get}
|
|
75
|
+
*/
|
|
76
|
+
interface ReposParams extends PaginationParams {
|
|
77
|
+
/** Filter by repository slug (case-insensitive prefix match) */
|
|
78
|
+
slug?: string;
|
|
79
|
+
/** Filter by repository name (case-insensitive prefix match) */
|
|
80
|
+
name?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Filter by the permission the authenticated user has on the repository.
|
|
83
|
+
* e.g. `'REPO_READ'`, `'REPO_WRITE'`, `'REPO_ADMIN'`
|
|
84
|
+
*/
|
|
85
|
+
permission?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A git ref (branch or tag) as referenced in a pull request. */
|
|
89
|
+
interface BitbucketRef {
|
|
90
|
+
id: string;
|
|
91
|
+
displayId: string;
|
|
92
|
+
latestCommit: string;
|
|
93
|
+
type: 'BRANCH' | 'TAG';
|
|
94
|
+
repository: {
|
|
95
|
+
slug: string;
|
|
96
|
+
id: number;
|
|
97
|
+
name: string;
|
|
98
|
+
links: Record<string, unknown>;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** A user participating in a pull request (author, reviewer, or participant). */
|
|
102
|
+
interface BitbucketParticipant {
|
|
103
|
+
user: {
|
|
104
|
+
name: string;
|
|
105
|
+
emailAddress: string;
|
|
106
|
+
id: number;
|
|
107
|
+
displayName: string;
|
|
108
|
+
active: boolean;
|
|
109
|
+
slug: string;
|
|
110
|
+
type: string;
|
|
111
|
+
};
|
|
112
|
+
role: 'AUTHOR' | 'REVIEWER' | 'PARTICIPANT';
|
|
113
|
+
approved: boolean;
|
|
114
|
+
status: 'APPROVED' | 'UNAPPROVED' | 'NEEDS_WORK';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Represents a Bitbucket Data Center pull request.
|
|
118
|
+
*/
|
|
119
|
+
interface BitbucketPullRequest {
|
|
120
|
+
id: number;
|
|
121
|
+
version: number;
|
|
122
|
+
title: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
state: 'OPEN' | 'DECLINED' | 'MERGED';
|
|
125
|
+
open: boolean;
|
|
126
|
+
closed: boolean;
|
|
127
|
+
createdDate: number;
|
|
128
|
+
updatedDate: number;
|
|
129
|
+
fromRef: BitbucketRef;
|
|
130
|
+
toRef: BitbucketRef;
|
|
131
|
+
locked: boolean;
|
|
132
|
+
author: BitbucketParticipant;
|
|
133
|
+
reviewers: BitbucketParticipant[];
|
|
134
|
+
participants: BitbucketParticipant[];
|
|
135
|
+
links: Record<string, unknown>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Query parameters accepted by `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests`.
|
|
139
|
+
*
|
|
140
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-pull-requests/#api-api-latest-projects-projectkey-repos-repositoryslug-pull-requests-get}
|
|
141
|
+
*/
|
|
142
|
+
interface PullRequestsParams extends PaginationParams {
|
|
143
|
+
/**
|
|
144
|
+
* Filter by state. Defaults to `'OPEN'`.
|
|
145
|
+
* Use `'ALL'` to retrieve pull requests in any state.
|
|
146
|
+
*/
|
|
147
|
+
state?: 'OPEN' | 'DECLINED' | 'MERGED' | 'ALL';
|
|
148
|
+
/**
|
|
149
|
+
* Filter by direction relative to the current user.
|
|
150
|
+
* - `'INCOMING'` — pull requests targeting a branch the user owns
|
|
151
|
+
* - `'OUTGOING'` — pull requests from branches the user owns
|
|
152
|
+
*/
|
|
153
|
+
direction?: 'INCOMING' | 'OUTGOING';
|
|
154
|
+
/** Filter by target branch ref (e.g., `'refs/heads/main'`) */
|
|
155
|
+
at?: string;
|
|
156
|
+
/** Sort order of results */
|
|
157
|
+
order?: 'NEWEST' | 'OLDEST' | 'MODIFIED' | 'CLOSED_DATE';
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Author/committer identity on a git commit. */
|
|
161
|
+
interface BitbucketCommitAuthor {
|
|
162
|
+
name: string;
|
|
163
|
+
emailAddress: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Represents a git commit in a Bitbucket Data Center repository.
|
|
167
|
+
*/
|
|
168
|
+
interface BitbucketCommit {
|
|
169
|
+
/** Full commit SHA */
|
|
170
|
+
id: string;
|
|
171
|
+
/** Abbreviated commit SHA */
|
|
172
|
+
displayId: string;
|
|
173
|
+
author: BitbucketCommitAuthor;
|
|
174
|
+
/** Unix timestamp (ms) of the author date */
|
|
175
|
+
authorTimestamp: number;
|
|
176
|
+
committer: BitbucketCommitAuthor;
|
|
177
|
+
/** Unix timestamp (ms) of the committer date */
|
|
178
|
+
committerTimestamp: number;
|
|
179
|
+
message: string;
|
|
180
|
+
parents: Array<{
|
|
181
|
+
id: string;
|
|
182
|
+
displayId: string;
|
|
183
|
+
}>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Query parameters accepted by `GET /rest/api/latest/projects/{key}/repos/{slug}/commits`.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://developer.atlassian.com/server/bitbucket/rest/v819/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-commits-get}
|
|
189
|
+
*/
|
|
190
|
+
interface CommitsParams extends PaginationParams {
|
|
191
|
+
/**
|
|
192
|
+
* The commit ID or ref to list commits reachable from.
|
|
193
|
+
* Defaults to the repository's default branch.
|
|
194
|
+
*/
|
|
195
|
+
until?: string;
|
|
196
|
+
/** Exclude commits reachable from this commit ID or ref */
|
|
197
|
+
since?: string;
|
|
198
|
+
/** Filter commits that touch this file path */
|
|
199
|
+
path?: string;
|
|
200
|
+
/** How to handle merge commits */
|
|
201
|
+
merges?: 'include' | 'exclude' | 'only';
|
|
202
|
+
/** Follow file renames when filtering by `path` */
|
|
203
|
+
followRenames?: boolean;
|
|
204
|
+
/** Silently ignore missing commits referenced by `since` or `until` */
|
|
205
|
+
ignoreMissing?: boolean;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Represents a Bitbucket repository resource with chainable async methods.
|
|
210
|
+
*
|
|
211
|
+
* Implements `PromiseLike<BitbucketRepository>` so it can be awaited directly
|
|
212
|
+
* to fetch repository info, while also exposing sub-resource methods.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* // Await directly to get repository info
|
|
217
|
+
* const repo = await bbClient.project('PROJ').repo('my-repo');
|
|
218
|
+
*
|
|
219
|
+
* // Get pull requests
|
|
220
|
+
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });
|
|
221
|
+
*
|
|
222
|
+
* // Get commits
|
|
223
|
+
* const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare class RepositoryResource implements PromiseLike<BitbucketRepository> {
|
|
227
|
+
private readonly request;
|
|
228
|
+
private readonly basePath;
|
|
229
|
+
/** @internal */
|
|
230
|
+
constructor(request: RequestFn, projectKey: string, repoSlug: string);
|
|
231
|
+
/**
|
|
232
|
+
* Allows the resource to be awaited directly, resolving with the repository info.
|
|
233
|
+
* Delegates to {@link RepositoryResource.get}.
|
|
234
|
+
*/
|
|
235
|
+
then<TResult1 = BitbucketRepository, TResult2 = never>(onfulfilled?: ((value: BitbucketRepository) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
236
|
+
/**
|
|
237
|
+
* Fetches the repository details.
|
|
238
|
+
*
|
|
239
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}`
|
|
240
|
+
*
|
|
241
|
+
* @returns The repository object
|
|
242
|
+
*/
|
|
243
|
+
get(): Promise<BitbucketRepository>;
|
|
244
|
+
/**
|
|
245
|
+
* Fetches pull requests for this repository.
|
|
246
|
+
*
|
|
247
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests`
|
|
248
|
+
*
|
|
249
|
+
* @param params - Optional filters: `limit`, `start`, `state`, `direction`, `at`, `order`
|
|
250
|
+
* @returns An array of pull requests
|
|
251
|
+
*/
|
|
252
|
+
pullRequests(params?: PullRequestsParams): Promise<BitbucketPullRequest[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Fetches commits for this repository.
|
|
255
|
+
*
|
|
256
|
+
* `GET /rest/api/latest/projects/{key}/repos/{slug}/commits`
|
|
257
|
+
*
|
|
258
|
+
* @param params - Optional filters: `limit`, `start`, `until`, `since`, `path`, `merges`, `followRenames`, `ignoreMissing`
|
|
259
|
+
* @returns An array of commits
|
|
260
|
+
*/
|
|
261
|
+
commits(params?: CommitsParams): Promise<BitbucketCommit[]>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** @internal */
|
|
265
|
+
type RequestFn = <T>(path: string, params?: Record<string, string | number | boolean>) => Promise<T>;
|
|
266
|
+
/**
|
|
267
|
+
* Represents a Bitbucket project resource with chainable async methods.
|
|
268
|
+
*
|
|
269
|
+
* Implements `PromiseLike<BitbucketProject>` so it can be awaited directly
|
|
270
|
+
* to fetch the project info, while also exposing sub-resource methods.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* // Await directly to get project info
|
|
275
|
+
* const project = await bbClient.project('PROJ');
|
|
276
|
+
*
|
|
277
|
+
* // Get repositories with filters
|
|
278
|
+
* const repos = await bbClient.project('PROJ').repos({ limit: 50, name: 'api' });
|
|
279
|
+
*
|
|
280
|
+
* // Navigate into a specific repository
|
|
281
|
+
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
declare class ProjectResource implements PromiseLike<BitbucketProject> {
|
|
285
|
+
private readonly request;
|
|
286
|
+
private readonly key;
|
|
287
|
+
/** @internal */
|
|
288
|
+
constructor(request: RequestFn, key: string);
|
|
289
|
+
/**
|
|
290
|
+
* Allows the resource to be awaited directly, resolving with the project info.
|
|
291
|
+
* Delegates to {@link ProjectResource.get}.
|
|
292
|
+
*/
|
|
293
|
+
then<TResult1 = BitbucketProject, TResult2 = never>(onfulfilled?: ((value: BitbucketProject) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
294
|
+
/**
|
|
295
|
+
* Fetches the project details.
|
|
296
|
+
*
|
|
297
|
+
* `GET /rest/api/latest/projects/{key}`
|
|
298
|
+
*
|
|
299
|
+
* @returns The project object
|
|
300
|
+
*/
|
|
301
|
+
get(): Promise<BitbucketProject>;
|
|
302
|
+
/**
|
|
303
|
+
* Fetches repositories belonging to this project.
|
|
304
|
+
*
|
|
305
|
+
* `GET /rest/api/latest/projects/{key}/repos`
|
|
306
|
+
*
|
|
307
|
+
* @param params - Optional filters: `limit`, `start`, `slug`, `name`, `permission`
|
|
308
|
+
* @returns An array of repositories
|
|
309
|
+
*/
|
|
310
|
+
repos(params?: ReposParams): Promise<BitbucketRepository[]>;
|
|
311
|
+
/**
|
|
312
|
+
* Returns a {@link RepositoryResource} for a given repository slug, providing
|
|
313
|
+
* access to repository-level data and sub-resources (pull requests, commits, etc.).
|
|
314
|
+
*
|
|
315
|
+
* The returned resource can be awaited directly to fetch repository info,
|
|
316
|
+
* or chained to access nested resources.
|
|
317
|
+
*
|
|
318
|
+
* @param repoSlug - The repository slug (e.g., `'my-repo'`)
|
|
319
|
+
* @returns A chainable repository resource
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const repo = await bbClient.project('PROJ').repo('my-repo');
|
|
324
|
+
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });
|
|
325
|
+
* const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
repo(repoSlug: string): RepositoryResource;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Constructor options for {@link BitbucketClient}.
|
|
333
|
+
*/
|
|
334
|
+
interface BitbucketClientOptions {
|
|
335
|
+
/** The base URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`) */
|
|
336
|
+
apiUrl: string;
|
|
337
|
+
/** The username to authenticate with */
|
|
338
|
+
user: string;
|
|
339
|
+
/** The personal access token or password to authenticate with */
|
|
340
|
+
token: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Main entry point for the Bitbucket Data Center REST API client.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const bbClient = new BitbucketClient({
|
|
348
|
+
* apiUrl: 'https://bitbucket.example.com',
|
|
349
|
+
* user: 'john.doe',
|
|
350
|
+
* token: 'my-token',
|
|
351
|
+
* });
|
|
352
|
+
*
|
|
353
|
+
* const projects = await bbClient.projects({ limit: 50 });
|
|
354
|
+
* const project = await bbClient.project('PROJ');
|
|
355
|
+
* const repos = await bbClient.project('PROJ').repos({ name: 'api' });
|
|
356
|
+
* const repo = await bbClient.project('PROJ').repo('my-repo');
|
|
357
|
+
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });
|
|
358
|
+
* const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare class BitbucketClient {
|
|
362
|
+
private readonly security;
|
|
363
|
+
/**
|
|
364
|
+
* @param options - Connection and authentication options
|
|
365
|
+
* @throws {TypeError} If `apiUrl` is not a valid URL
|
|
366
|
+
*/
|
|
367
|
+
constructor({ apiUrl, user, token }: BitbucketClientOptions);
|
|
368
|
+
/**
|
|
369
|
+
* Performs an authenticated GET request to the Bitbucket REST API.
|
|
370
|
+
*
|
|
371
|
+
* @param path - API path relative to `/rest/api/latest` (e.g., `'/projects'`)
|
|
372
|
+
* @param params - Optional query parameters to append to the URL
|
|
373
|
+
* @throws {Error} If the HTTP response is not OK
|
|
374
|
+
* @internal
|
|
375
|
+
*/
|
|
376
|
+
private request;
|
|
377
|
+
/**
|
|
378
|
+
* Fetches all projects accessible to the authenticated user.
|
|
379
|
+
*
|
|
380
|
+
* `GET /rest/api/latest/projects`
|
|
381
|
+
*
|
|
382
|
+
* @param params - Optional filters: `limit`, `start`, `name`, `permission`
|
|
383
|
+
* @returns An array of projects
|
|
384
|
+
*/
|
|
385
|
+
projects(params?: ProjectsParams): Promise<BitbucketProject[]>;
|
|
386
|
+
/**
|
|
387
|
+
* Returns a {@link ProjectResource} for a given project key, providing access
|
|
388
|
+
* to project-level data and sub-resources.
|
|
389
|
+
*
|
|
390
|
+
* The returned resource can be awaited directly to fetch project info,
|
|
391
|
+
* or chained to access nested resources.
|
|
392
|
+
*
|
|
393
|
+
* @param projectKey - The project key (e.g., `'PROJ'`)
|
|
394
|
+
* @returns A chainable project resource
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```typescript
|
|
398
|
+
* const project = await bbClient.project('PROJ');
|
|
399
|
+
* const repos = await bbClient.project('PROJ').repos({ limit: 10 });
|
|
400
|
+
* const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests();
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
project(projectKey: string): ProjectResource;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Handles Basic Authentication for Bitbucket Data Center REST API requests.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* const security = new Security(
|
|
412
|
+
* 'https://bitbucket.example.com',
|
|
413
|
+
* 'my-user',
|
|
414
|
+
* 'my-token'
|
|
415
|
+
* );
|
|
416
|
+
*
|
|
417
|
+
* const headers = security.getHeaders();
|
|
418
|
+
* // { Authorization: 'Basic <base64>', 'Content-Type': 'application/json', Accept: 'application/json' }
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
declare class Security {
|
|
422
|
+
private readonly apiUrl;
|
|
423
|
+
private readonly authorizationHeader;
|
|
424
|
+
/**
|
|
425
|
+
* Creates a new Security instance with Basic Authentication credentials.
|
|
426
|
+
*
|
|
427
|
+
* @param apiUrl - The base URL of the Bitbucket Data Center instance (e.g., `https://bitbucket.example.com`).
|
|
428
|
+
* Must be a valid URL; throws if it cannot be parsed.
|
|
429
|
+
* @param user - The username to authenticate with
|
|
430
|
+
* @param token - The personal access token or password to authenticate with
|
|
431
|
+
*
|
|
432
|
+
* @throws {TypeError} If `apiUrl` is not a valid URL
|
|
433
|
+
*/
|
|
434
|
+
constructor(apiUrl: string, user: string, token: string);
|
|
435
|
+
/**
|
|
436
|
+
* Returns the base URL of the Bitbucket Data Center instance, without a trailing slash.
|
|
437
|
+
*
|
|
438
|
+
* @returns The API base URL
|
|
439
|
+
*/
|
|
440
|
+
getApiUrl(): string;
|
|
441
|
+
/**
|
|
442
|
+
* Returns the value of the `Authorization` header for Basic Authentication.
|
|
443
|
+
*
|
|
444
|
+
* @returns The Authorization header value in the format `Basic <base64-encoded-credentials>`
|
|
445
|
+
*/
|
|
446
|
+
getAuthorizationHeader(): string;
|
|
447
|
+
/**
|
|
448
|
+
* Returns the full set of HTTP headers required for authenticated API requests.
|
|
449
|
+
*
|
|
450
|
+
* @returns An object containing `Authorization`, `Content-Type`, and `Accept` headers
|
|
451
|
+
*/
|
|
452
|
+
getHeaders(): Record<string, string>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export { BitbucketClient, type BitbucketClientOptions, type BitbucketCommit, type BitbucketCommitAuthor, type BitbucketParticipant, type BitbucketProject, type BitbucketPullRequest, type BitbucketRef, type BitbucketRepository, type CommitsParams, type PagedResponse, type PaginationParams, ProjectResource, type ProjectsParams, type PullRequestsParams, type ReposParams, RepositoryResource, Security };
|