Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BITBUCKET_CLOUD_URL=https://api.bitbucket.org/2.0
BITBUCKET_CLOUD_USERNAME=
BITBUCKET_CLOUD_APP_PASSWORD=

BITBUCKET_SERVER_URL=
BITBUCKET_SERVER_TOKEN=
5 changes: 5 additions & 0 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ jobs:
- run: pnpm run build --noEmit
- run: pnpm run lint
- run: pnpm run test run
env:
BITBUCKET_CLOUD_USERNAME: ${{ secrets.BITBUCKET_CLOUD_USERNAME }}
BITBUCKET_CLOUD_APP_PASSWORD: ${{ secrets.BITBUCKET_CLOUD_APP_PASSWORD }}
BITBUCKET_SERVER_URL: ${{ secrets.BITBUCKET_SERVER_URL }}
BITBUCKET_SERVER_TOKEN: ${{ secrets.BITBUCKET_SERVER_TOKEN }}
3 changes: 3 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default: true
line-length: false
no-inline-html: false
no-hard-tabs:
code_blocks: false
spaces_per_tab: 2
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,49 @@
[![Node.js CI](https://github.com/coderabbitai/bitbucket/actions/workflows/node.js.yaml/badge.svg)](https://github.com/coderabbitai/bitbucket/actions/workflows/node.js.yaml) [![Dependabot Updates](https://github.com/coderabbitai/bitbucket/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/coderabbitai/bitbucket/actions/workflows/dependabot/dependabot-updates) [![GitHub Pages](https://github.com/coderabbitai/bitbucket/actions/workflows/github-pages.yaml/badge.svg)](https://github.com/coderabbitai/bitbucket/actions/workflows/github-pages.yaml)

CodeRabbit's TypeScript API client for connecting to Bitbucket Cloud and Bitbucker Data Center.

- Bitbucket Cloud API docs: <https://developer.atlassian.com/cloud/bitbucket/rest>
- Bitbucket Data Center API docs: <https://developer.atlassian.com/server/bitbucket/rest>

This client is auto-generated by [https://github.com/openapi-ts/openapi-typescript](https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-typescript) using the OpenAPI schema from the documentation above.

## Usage

```sh
pnpm i @coderabbitai/bitbucket
```

### Cloud

```ts
import { createBitbucketCloudClient, toBase64 } from "@coderabbitai/bitbucket"
import {
BITBUCKET_CLOUD_APP_PASSWORD,
BITBUCKET_CLOUD_URL,
BITBUCKET_CLOUD_USERNAME,
} from "./env.js"

const basic = toBase64(
BITBUCKET_CLOUD_USERNAME + ":" + BITBUCKET_CLOUD_APP_PASSWORD,
)

export const client = createBitbucketCloudClient({
baseUrl: BITBUCKET_CLOUD_URL.toString(),
headers: { Accept: "application/json", Authorization: `Basic ${basic}` },
})
```

### Server

```ts
import { createBitbucketServerClient } from "@coderabbitai/bitbucket"
import { BITBUCKET_SERVER_TOKEN, BITBUCKET_SERVER_URL } from "./env.js"

export const server = createBitbucketServerClient({
baseUrl: BITBUCKET_SERVER_URL,
headers: {
Accept: "application/json",
Authorization: `Bearer ${BITBUCKET_SERVER_TOKEN}`,
},
})
```
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@
"lint": "eslint . && markdownlint-cli2 \"**/*.md\" && prettier --check .",
"lint:fix": "eslint --fix --quiet .; markdownlint-cli2 \"**/*.md\" --fix; prettier --list-different --write .",
"start": "node dist/main.js",
"test": "vitest"
"test": "vitest",
"openapi-typescript": "pnpm run openapi-typescript:cloud && pnpm run openapi-typescript:server",
"preopenapi-typescript:cloud": "curl --output ./src/cloud/openapi/swagger.v3.json https://dac-static.atlassian.com/cloud/bitbucket/swagger.v3.json",
"openapi-typescript:cloud": "openapi-typescript ./src/cloud/openapi/swagger.v3.json --output ./src/cloud/openapi/openapi-typescript.ts --immutable --empty-objects-unknown --alphabetize --root-types",
"postopenapi-typescript:cloud": "ts-autofix ./src/cloud/openapi && pnpm run lint:fix",
"preopenapi-typescript:server": "curl --output ./src/server/openapi/swagger.v3.json https://dac-static.atlassian.com/server/bitbucket/9.1.swagger.v3.json",
"openapi-typescript:server": "openapi-typescript ./src/server/openapi/swagger.v3.json --output ./src/server/openapi/openapi-typescript.ts --immutable --empty-objects-unknown --alphabetize --root-types",
"postopenapi-typescript:server": "ts-autofix ./src/server/openapi && pnpm run lint:fix"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
Expand All @@ -46,6 +53,7 @@
"eslint-config-prettier": "^9.1.0",
"globals": "^15.9.0",
"markdownlint-cli2": "^0.14.0",
"openapi-typescript": "^7.4.0",
"prettier": "^3.3.3",
"tsx": "^4.19.1",
"typedoc": "^0.26.7",
Expand All @@ -61,5 +69,8 @@
}
},
"types": "dist/index.d.ts",
"module": "dist/index.js"
"module": "dist/index.js",
"dependencies": {
"openapi-fetch": "^0.12.0"
}
}
Loading