Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coderabbitai/bitbucket
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.5
Choose a base ref
...
head repository: coderabbitai/bitbucket
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 8,836 additions and 6,149 deletions.
  1. +3 −0 .env
  2. +5 −0 .gitattributes
  3. +0 −1 .github/authorized_keys
  4. +98 −4 .github/workflows/node.js.yaml
  5. +1 −8 .github/workflows/pnpm-publish.yaml
  6. +68 −20 .github/workflows/pnpm-version-patch.yaml
  7. +4 −0 .gitignore
  8. +4 −3 README.md
  9. +37 −19 package.json
  10. +1,230 −1,013 pnpm-lock.yaml
  11. +8 −0 scripts/pnpm_version_patch.sh
  12. +1 −1 src/base64.test.ts
  13. +6 −6 src/base64.ts
  14. +1 −1 src/cloud/client.test.ts
  15. +1 −1 src/cloud/client.ts
  16. +3 −2 src/cloud/index.ts
  17. +1 −0 src/cloud/interfaces/index.ts
  18. +30 −0 src/cloud/interfaces/paths.test.ts
  19. +35 −0 src/cloud/interfaces/paths.ts
  20. +1 −1 src/cloud/openapi/index.ts
  21. +427 −75 src/cloud/openapi/openapi-typescript.ts
  22. +1,797 −1,136 src/cloud/openapi/swagger.v3.json
  23. +1 −1 src/index.test.ts
  24. +3 −3 src/index.ts
  25. +1 −1 src/server/client.test.ts
  26. +1 −1 src/server/client.ts
  27. +4 −3 src/server/index.ts
  28. +1 −0 src/server/interfaces/index.ts
  29. +47 −0 src/server/interfaces/schema_rest_pull_request_activity.ts
  30. +1 −1 src/server/openapi/index.ts
  31. +427 −9 src/server/openapi/openapi-typescript.ts
  32. +4,141 −3,572 src/server/openapi/swagger.v3.json
  33. +6 −6 src/server/webhooks/events/event.ts
  34. +5 −4 src/server/webhooks/events/index.ts
  35. +50 −9 src/server/webhooks/events/pr/comment_added.ts
  36. +9 −4 src/server/webhooks/events/pr/comment_deleted.ts
  37. +7 −5 src/server/webhooks/events/pr/comment_edited.ts
  38. +19 −3 src/server/webhooks/events/pr/declined.ts
  39. +8 −3 src/server/webhooks/events/pr/deleted.ts
  40. +2 −2 src/server/webhooks/events/pr/event.test.ts
  41. +14 −14 src/server/webhooks/events/pr/event.ts
  42. +9 −4 src/server/webhooks/events/pr/from_ref_updated.ts
  43. +13 −13 src/server/webhooks/events/pr/index.ts
  44. +8 −3 src/server/webhooks/events/pr/merged.ts
  45. +38 −14 src/server/webhooks/events/pr/modified.ts
  46. +34 −4 src/server/webhooks/events/pr/opened.ts
  47. +8 −3 src/server/webhooks/events/pr/reviewer_approved.ts
  48. +8 −3 src/server/webhooks/events/pr/reviewer_changes_requested.ts
  49. +8 −3 src/server/webhooks/events/pr/reviewer_unapproved.ts
  50. +40 −6 src/server/webhooks/events/pr/reviewer_updated.ts
  51. +2 −2 src/server/webhooks/events/project/event.test.ts
  52. +2 −2 src/server/webhooks/events/project/event.ts
  53. +2 −2 src/server/webhooks/events/project/index.ts
  54. +3 −1 src/server/webhooks/events/repo/comment_added.ts
  55. +3 −1 src/server/webhooks/events/repo/comment_deleted.ts
  56. +3 −1 src/server/webhooks/events/repo/comment_edited.ts
  57. +2 −2 src/server/webhooks/events/repo/event.test.ts
  58. +9 −9 src/server/webhooks/events/repo/event.ts
  59. +4 −2 src/server/webhooks/events/repo/forked.ts
  60. +9 −9 src/server/webhooks/events/repo/index.ts
  61. +3 −1 src/server/webhooks/events/repo/modified.ts
  62. +3 −1 src/server/webhooks/events/repo/refs_changed.ts
  63. +3 −1 src/server/webhooks/events/repo/secret_detected.ts
  64. +3 −1 src/server/webhooks/events/repo/synchronized.ts
  65. +6 −0 src/server/webhooks/events/suggestion_state.ts
  66. +1 −1 src/server/webhooks/headers.ts
  67. +2 −2 src/server/webhooks/index.ts
  68. +4 −3 tests/cloud/client.ts
  69. +3 −2 tests/cloud/repositories.test.ts
  70. +22 −65 tests/env.ts
  71. +2 −2 tests/server/client.ts
  72. +4 −3 tests/server/projects.test.ts
  73. +58 −50 tests/server/repositories.test.ts
  74. +1 −0 tsconfig.eslint.json
  75. +2 −0 tsconfig.json
  76. +6 −1 typedoc.json
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -6,3 +6,6 @@ BITBUCKET_SERVER_URL=
BITBUCKET_SERVER_TOKEN=
BITBUCKET_SERVER_TEST_PROJECT_KEY=
BITBUCKET_SERVER_TEST_PROJECT_NAME=

SKIP_BITBUCKET_CLOUD=false
SKIP_BITBUCKET_SERVER=true
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pnpm-lock.yaml linguist-generated
src/cloud/openapi/openapi-typescript.ts linguist-generated
src/cloud/openapi/swagger.v3.json linguist-generated
src/server/openapi/openapi-typescript.ts linguist-generated
src/server/openapi/swagger.v3.json linguist-generated
1 change: 0 additions & 1 deletion .github/authorized_keys

This file was deleted.

102 changes: 98 additions & 4 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Node.js CI

on:
push:
branches: main
merge_group:
branches:
- main
pull_request:
branches: main
branches:
- main
push:
branches:
- main

jobs:
test:
@@ -19,10 +24,28 @@ jobs:
with:
node-version: latest
cache: pnpm

- name: Install Twingate
run: |
echo "deb [trusted=yes] https://packages.twingate.com/apt/ /" | sudo tee /etc/apt/sources.list.d/twingate.list
sudo apt update -yq
sudo apt install -yq twingate
- name: Setup and start Twingate
env:
TWINGATE_SERVICE_KEY: ${{ secrets.TWINGATE_SCM_TOOLS_SERVICE_KEY }}
run: |
echo $TWINGATE_SERVICE_KEY | sudo twingate setup --headless=-
sudo twingate start
- name: Twingate status
run: twingate status

- run: pnpm install --frozen-lockfile --strict-peer-dependencies
- run: pnpm run build --noEmit
- run: pnpm run lint
- run: pnpm run test run

- run: pnpm run test
if: github.actor != 'dependabot[bot]'
env:
BITBUCKET_CLOUD_USERNAME: ${{ secrets.BITBUCKET_CLOUD_USERNAME }}
@@ -31,3 +54,74 @@ jobs:
BITBUCKET_SERVER_TOKEN: ${{ secrets.BITBUCKET_SERVER_TOKEN }}
BITBUCKET_SERVER_TEST_PROJECT_KEY: ${{ vars.BITBUCKET_SERVER_TEST_PROJECT_KEY }}
BITBUCKET_SERVER_TEST_PROJECT_NAME: ${{ vars.BITBUCKET_SERVER_TEST_PROJECT_NAME }}
SKIP_BITBUCKET_CLOUD: ${{ vars.SKIP_BITBUCKET_CLOUD }}
SKIP_BITBUCKET_SERVER: ${{ vars.SKIP_BITBUCKET_SERVER }}

fix:
runs-on: ubuntu-latest

permissions:
contents: write

needs:
- test

if: failure() && github.event_name != 'merge_group' && github.actor != 'github-actions[bot]' && github.actor != 'nektos/act'

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
ssh-key: ${{ secrets.DEPLOY_KEY_PRIVATE }}
- uses: pnpm/action-setup@v4
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: latest

- run: |
pnpm install --fix-lockfile --no-frozen-lockfile
git add .
- id: commit-lockfile
uses: qoomon/actions--create-commit@v1
with:
message: |
📌 pnpm install --fix-lockfile
[dependabot skip]
skip-empty: true

- run: |
pnpm run format
git add .
- id: commit-format
uses: qoomon/actions--create-commit@v1
with:
message: |
🎨 pnpm run format
[dependabot skip]
skip-empty: true

- run: |
pnpm run lint:fix
git add .
- id: commit-lint
uses: qoomon/actions--create-commit@v1
with:
message: |
🚨 pnpm run lint:fix
[dependabot skip]
skip-empty: true

- name: Push
if: steps.commit-lockfile.outputs.commit || steps.commit-format.outputs.commit || steps.commit-lint.outputs.commit
run: |
eval `ssh-agent -s`
ssh-add - <<< "$DEPLOY_KEY_PRIVATE"
git push
env:
DEPLOY_KEY_PRIVATE: ${{ secrets.DEPLOY_KEY_PRIVATE }}
9 changes: 1 addition & 8 deletions .github/workflows/pnpm-publish.yaml
Original file line number Diff line number Diff line change
@@ -45,13 +45,6 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.CODERABBIT_NPM_TOKEN }}

- run: pnpm pack --pack-gzip-level 9
- name: Sign
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.DEPLOY_KEY_PRIVATE }}'
echo '${{ vars.DEPLOY_KEY_PUBLIC }}' > '${{ runner.temp }}/DEPLOY_KEY_PUBLIC.pub'
ssh-keygen -Y sign -f '${{ runner.temp }}/DEPLOY_KEY_PUBLIC.pub' -n file coderabbitai-bitbucket-*.tgz
ssh-keygen -Y verify -f ./.github/authorized_keys -I '41898282+github-actions[bot]@users.noreply.github.com' -n file -s coderabbitai-bitbucket-*.tgz.sig < coderabbitai-bitbucket-*.tgz
- run: gh release upload ${{ github.ref_name }} coderabbitai-bitbucket-*.tgz coderabbitai-bitbucket-*.tgz.sig
- run: gh release upload ${{ github.ref_name }} coderabbitai-bitbucket-*.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88 changes: 68 additions & 20 deletions .github/workflows/pnpm-version-patch.yaml
Original file line number Diff line number Diff line change
@@ -6,43 +6,91 @@ jobs:
patch:
runs-on: ubuntu-latest

if: github.actor != 'nektos/act' && github.ref_name == 'main'

permissions:
contents: write

if: github.actor != 'nektos/act' && github.ref_name == 'main'
outputs:
version: ${{ steps.patch.outputs.VERSION }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
ssh-key: ${{ secrets.DEPLOY_KEY_PRIVATE }}
- uses: pnpm/action-setup@v4
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: latest
- name: Configure Git, patch, release and push

- id: patch
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
echo "VERSION=$(pnpm version patch --no-git-tag-version)" >> "$GITHUB_OUTPUT"
git add .
git config commit.gpgsign true
git config gpg.format ssh
git config push.gpgSign 'if-asked'
git config tag.gpgSign true
git config user.signingkey 'key::${{ vars.DEPLOY_KEY_PUBLIC }}'
- id: commit
uses: qoomon/actions--create-commit@v1
with:
message: 🔖 ${{ steps.patch.outputs.VERSION }}

- name: Push
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.DEPLOY_KEY_PRIVATE }}'
ssh-add - <<< "$DEPLOY_KEY_PRIVATE"
git push
env:
DEPLOY_KEY_PRIVATE: ${{ secrets.DEPLOY_KEY_PRIVATE }}

VERSION=$(pnpm version patch --no-git-tag-version)
- run: gh release create "$VERSION" --generate-notes --target "$COMMIT" --title "$VERSION"
env:
COMMIT: ${{ steps.commit.outputs.commit }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.patch.outputs.VERSION }}

git commit --all --message "🔖 $VERSION"
git tag --annotate --message "🔖 $VERSION" --sign $VERSION
git push
git push --tags
publish:
runs-on: ubuntu-latest

needs: patch

permissions:
contents: write # Upload the release files
id-token: write # Add `--provenance`
packages: write # Publish the package

if: github.actor != 'nektos/act'

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.patch.outputs.version }}
- uses: pnpm/action-setup@v4
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: latest
- run: pnpm install
- run: pnpm build

- uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com
scope: "@coderabbitai"
- run: pnpm publish --access public --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org
scope: "@coderabbitai"
- run: pnpm publish --access public --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.CODERABBIT_NPM_TOKEN }}

gh release create $VERSION --generate-notes --title $VERSION --verify-tag
- run: pnpm pack --pack-gzip-level 9
- run: gh release upload "$VERSION" coderabbitai-bitbucket-*.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.patch.outputs.version }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -8,6 +8,10 @@ package-lock.json
.env.*.local
.env.local


### JetBrains ###
.idea

# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows,node
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows,node

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `@coderabbitai/bitbucket`

[![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) [![GitHub Downloads](https://img.shields.io/github/downloads/coderabbitai/bitbucket/total?logo=github&color=0969da)](https://github.com/coderabbitai/bitbucket/releases) [![NPM Downloads](https://img.shields.io/npm/dt/%40coderabbitai/bitbucket?logo=npm&color=CB3837)](https://www.npmjs.com/package/@coderabbitai/bitbucket)
[![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) [![GitHub Downloads](https://img.shields.io/github/downloads/coderabbitai/bitbucket/total?logo=github&color=0969da)](https://github.com/coderabbitai/bitbucket/releases) [![NPM Downloads](https://img.shields.io/npm/dt/%40coderabbitai/bitbucket?logo=npm&color=CB3837)](https://www.npmjs.com/package/@coderabbitai/bitbucket) ![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/coderabbitai/bitbucket?labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit%20Reviews)

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

@@ -18,7 +18,8 @@ pnpm i @coderabbitai/bitbucket
### Cloud

```ts
import { createBitbucketCloudClient, toBase64 } from "@coderabbitai/bitbucket"
import { createBitbucketCloudClient } from "@coderabbitai/bitbucket/cloud"
import { toBase64 } from "@coderabbitai/bitbucket"
import {
BITBUCKET_CLOUD_APP_PASSWORD,
BITBUCKET_CLOUD_URL,
@@ -38,7 +39,7 @@ const client = createBitbucketCloudClient({
### Server

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

const server = createBitbucketServerClient({
56 changes: 37 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coderabbitai/bitbucket",
"version": "1.0.5",
"version": "1.1.3",
"description": "CodeRabbit's TypeScript API client for connecting to Bitbucket Cloud and Bitbucket Data Center",
"keywords": [
"bitbucket-api-v1",
@@ -33,45 +33,63 @@
"scripts": {
"build": "tsc",
"clean": "rm -rf dist docs node_modules tsconfig.tsbuildinfo",
"dev": "tsx ./src/main.ts",
"dev": "node ./src/main.ts",
"docs": "typedoc",
"format": "prettier --write .",
"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 run",
"test:watch": "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",
"preopenapi-typescript:server": "curl --output ./src/server/openapi/swagger.v3.json https://dac-static.atlassian.com/server/bitbucket/9.2.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"
},
"dependencies": {
"openapi-fetch": "^0.12.0"
"openapi-fetch": "^0.13.4"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@types/node": "^22.5.5",
"dotenv": "^16.4.5",
"eslint": "^9.10.0",
"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",
"typescript": "^5.6.2",
"typescript-eslint": "^8.6.0",
"vitest": "^2.1.1"
"@eslint/js": "^9.21.0",
"@natoboram/load_env": "^1.0.0",
"@types/node": "^22.13.5",
"dotenv": "^16.4.7",
"eslint": "^9.21.0",
"eslint-config-prettier": "^10.0.2",
"globals": "^16.0.0",
"markdownlint-cli2": "^0.17.2",
"openapi-typescript": "^7.6.1",
"prettier": "^3.5.2",
"ts-autofix": "^1.0.0",
"typedoc": "^0.28.1",
"typescript": "5.8.3",
"typescript-eslint": "^8.25.0",
"vitest": "^3.0.7"
},
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./cloud": {
"types": "./dist/cloud/index.d.ts",
"default": "./dist/cloud/index.js"
},
"./cloud/openapi": {
"types": "./dist/cloud/openapi/index.d.ts",
"default": "./dist/cloud/openapi/index.js"
},
"./server": {
"types": "./dist/server/index.d.ts",
"default": "./dist/server/index.js"
},
"./server/openapi": {
"types": "./dist/server/openapi/index.d.ts",
"default": "./dist/server/openapi/index.js"
}
},
"types": "dist/index.d.ts",
Loading