bitbucket-datacenter-api-client 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +208 -0
- package/dist/index.d.mts +545 -19
- package/dist/index.d.ts +545 -19
- package/dist/index.js +260 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +260 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# bitbucket-datacenter-api-client
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ElJijuna/BitbucketDataCenterApiClient/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/bitbucket-datacenter-api-client)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
TypeScript client for the [Bitbucket Data Center REST API](https://developer.atlassian.com/server/bitbucket/rest/v819/intro/).
|
|
8
|
+
Works in **Node.js** and the **browser** (isomorphic). Fully typed, zero runtime dependencies.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install bitbucket-datacenter-api-client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { BitbucketClient } from 'bitbucket-datacenter-api-client';
|
|
24
|
+
|
|
25
|
+
const bb = new BitbucketClient({
|
|
26
|
+
apiUrl: 'https://bitbucket.example.com',
|
|
27
|
+
apiPath: 'rest/api/latest',
|
|
28
|
+
user: 'your-username',
|
|
29
|
+
token: 'your-personal-access-token',
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## API reference
|
|
36
|
+
|
|
37
|
+
### Projects
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// List all accessible projects
|
|
41
|
+
const projects = await bb.projects();
|
|
42
|
+
const projects = await bb.projects({ limit: 50, name: 'platform' });
|
|
43
|
+
|
|
44
|
+
// Get a single project
|
|
45
|
+
const project = await bb.project('PROJ');
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Repositories
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// List repositories in a project
|
|
52
|
+
const repos = await bb.project('PROJ').repos();
|
|
53
|
+
const repos = await bb.project('PROJ').repos({ limit: 25, name: 'api' });
|
|
54
|
+
|
|
55
|
+
// Get a single repository
|
|
56
|
+
const repo = await bb.project('PROJ').repo('my-repo');
|
|
57
|
+
|
|
58
|
+
// Repository size (bytes)
|
|
59
|
+
const size = await bb.project('PROJ').repo('my-repo').size();
|
|
60
|
+
// { repository: 1048576, attachments: 0 }
|
|
61
|
+
|
|
62
|
+
// Files last modified (with the commit that touched each)
|
|
63
|
+
const entries = await bb.project('PROJ').repo('my-repo').lastModified();
|
|
64
|
+
const entries = await bb.project('PROJ').repo('my-repo').lastModified({ at: 'main' });
|
|
65
|
+
|
|
66
|
+
// Raw file content
|
|
67
|
+
const content = await bb.project('PROJ').repo('my-repo').raw('src/index.ts');
|
|
68
|
+
const content = await bb.project('PROJ').repo('my-repo').raw('src/index.ts', { at: 'feature/my-branch' });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Branches
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const branches = await bb.project('PROJ').repo('my-repo').branches();
|
|
75
|
+
const branches = await bb.project('PROJ').repo('my-repo').branches({
|
|
76
|
+
filterText: 'feature',
|
|
77
|
+
orderBy: 'MODIFICATION',
|
|
78
|
+
details: true,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Commits
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Repository commits
|
|
86
|
+
const commits = await bb.project('PROJ').repo('my-repo').commits();
|
|
87
|
+
const commits = await bb.project('PROJ').repo('my-repo').commits({
|
|
88
|
+
limit: 25,
|
|
89
|
+
until: 'main',
|
|
90
|
+
path: 'src/index.ts',
|
|
91
|
+
followRenames: true,
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Pull requests
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// List pull requests
|
|
99
|
+
const prs = await bb.project('PROJ').repo('my-repo').pullRequests();
|
|
100
|
+
const prs = await bb.project('PROJ').repo('my-repo').pullRequests({
|
|
101
|
+
state: 'OPEN',
|
|
102
|
+
order: 'NEWEST',
|
|
103
|
+
limit: 10,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Get a single pull request
|
|
107
|
+
const pr = await bb.project('PROJ').repo('my-repo').pullRequest(42);
|
|
108
|
+
|
|
109
|
+
// Pull request sub-resources
|
|
110
|
+
const activities = await bb.project('PROJ').repo('my-repo').pullRequest(42).activities();
|
|
111
|
+
const tasks = await bb.project('PROJ').repo('my-repo').pullRequest(42).tasks();
|
|
112
|
+
const commits = await bb.project('PROJ').repo('my-repo').pullRequest(42).commits();
|
|
113
|
+
const changes = await bb.project('PROJ').repo('my-repo').pullRequest(42).changes();
|
|
114
|
+
const reports = await bb.project('PROJ').repo('my-repo').pullRequest(42).reports();
|
|
115
|
+
const summaries = await bb.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();
|
|
116
|
+
const issues = await bb.project('PROJ').repo('my-repo').pullRequest(42).issues();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Users
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// List all users
|
|
123
|
+
const users = await bb.users();
|
|
124
|
+
const users = await bb.users({ filter: 'john', limit: 20 });
|
|
125
|
+
|
|
126
|
+
// Get a single user
|
|
127
|
+
const user = await bb.user('pilmee');
|
|
128
|
+
|
|
129
|
+
// Users with access to a project
|
|
130
|
+
const members = await bb.project('PROJ').users();
|
|
131
|
+
const members = await bb.project('PROJ').users({ permission: 'PROJECT_WRITE' });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Chainable resource pattern
|
|
137
|
+
|
|
138
|
+
Every resource that maps to a single entity (project, repo, pull request, user) implements `PromiseLike`, so you can **await it directly** to fetch the entity, or **chain methods** to access sub-resources — without an extra `.get()` call:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Await directly → fetches the project
|
|
142
|
+
const project = await bb.project('PROJ');
|
|
143
|
+
|
|
144
|
+
// Chain → fetches the repositories list
|
|
145
|
+
const repos = await bb.project('PROJ').repos({ limit: 10 });
|
|
146
|
+
|
|
147
|
+
// Deep chain → fetches PR activities
|
|
148
|
+
const activities = await bb.project('PROJ').repo('my-repo').pullRequest(42).activities();
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Authentication
|
|
154
|
+
|
|
155
|
+
The client uses **HTTP Basic Authentication** with a Personal Access Token (PAT). Generate one in Bitbucket under **Profile → Manage account → Personal access tokens**.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const bb = new BitbucketClient({
|
|
159
|
+
apiUrl: 'https://bitbucket.example.com',
|
|
160
|
+
apiPath: 'rest/api/latest',
|
|
161
|
+
user: 'your-username',
|
|
162
|
+
token: 'your-personal-access-token',
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## TypeScript types
|
|
169
|
+
|
|
170
|
+
All domain types are exported and fully typed:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import type {
|
|
174
|
+
BitbucketProject,
|
|
175
|
+
BitbucketRepository,
|
|
176
|
+
BitbucketBranch,
|
|
177
|
+
BitbucketCommit,
|
|
178
|
+
BitbucketPullRequest,
|
|
179
|
+
BitbucketPullRequestActivity,
|
|
180
|
+
BitbucketPullRequestTask,
|
|
181
|
+
BitbucketChange,
|
|
182
|
+
BitbucketReport,
|
|
183
|
+
BitbucketBuildSummaries,
|
|
184
|
+
BitbucketIssue,
|
|
185
|
+
BitbucketUser,
|
|
186
|
+
BitbucketRepositorySize,
|
|
187
|
+
BitbucketLastModifiedEntry,
|
|
188
|
+
} from 'bitbucket-datacenter-api-client';
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Documentation
|
|
194
|
+
|
|
195
|
+
Full API documentation is published at:
|
|
196
|
+
**[https://eljijuna.github.io/BitbucketDataCenterApiClient](https://eljijuna.github.io/BitbucketDataCenterApiClient)**
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
[MIT](LICENSE)
|