Skip to content
Open
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
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@
"name": "bitbucket",
"version": "1.15.2",
"description": "Bitbucket API client for Browser and Node.js",
"keywords": ["bitbucket", "bitbucket-api", "api-client", "api", "rest"],
"keywords": [
"bitbucket",
"bitbucket-api",
"api-client",
"api",
"rest"
],
"homepage": "https://github.com/MunifTanjim/node-bitbucket#readme",
"bugs": "https://github.com/MunifTanjim/node-bitbucket/issues",
"license": "MIT",
"author": "MunifTanjim (https://muniftanjim.com)",
"files": ["src", "dist/*.js"],
"files": [
"src",
"dist/*.js"
],
"main": "src/index.js",
"types": "src/index.d.ts",
"browser": {
"./src/utils/get-buffer-response.js":
"./src/utils/get-buffer-response-browser.js"
"./src/utils/get-buffer-response.js": "./src/utils/get-buffer-response-browser.js"
},
"repository": "github:MunifTanjim/node-bitbucket",
"scripts": {
"build": "npm-run-all -p build:*",
"prebuild:browser": "mkdirp dist",
"build:browser": "npm-run-all -p build:browser:*",
"build:browser:development": "webpack --mode development",
"build:browser:production":
"webpack --mode production --output-filename=bitbucket.min.js",
"build:browser:production": "webpack --mode production --output-filename=bitbucket.min.js",
"prebuild:docs": "mkdirp docs",
"build:docs": "npm run generate:api-docs",
"postbuild:docs": "apidoc -i docs -o docs",
Expand All @@ -45,6 +52,7 @@
"debug": "^3.1.0",
"is-plain-object": "^2.0.4",
"node-fetch": "^2.1.2",
"qs": "^6.9.1",
"url-template": "^2.0.8"
},
"devDependencies": {
Expand Down
17 changes: 10 additions & 7 deletions scripts/type-defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4064,13 +4064,16 @@
"$ref": "#/definitions/PullrequestEndpoint"
},
"state": {
"enum": [
"MERGED",
"SUPERSEDED",
"OPEN",
"DECLINED"
],
"type": "string"
"items": {
"enum": [
"MERGED",
"SUPERSEDED",
"OPEN",
"DECLINED"
],
"type": "string"
},
"type": "array"
},
"summary": {
"additionalProperties": false,
Expand Down
5 changes: 4 additions & 1 deletion specification/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4914,13 +4914,16 @@
},
"state": {
"description": "The pull request's current status.",
"enum": [
"items": {
"enum": [
"MERGED",
"SUPERSEDED",
"OPEN",
"DECLINED"
],
"type": "string"
},
"type": "array"
},
"summary": {
"additionalProperties": false,
Expand Down
19 changes: 11 additions & 8 deletions src/routes/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3844,14 +3844,17 @@
"type": "string"
},
"state": {
"enum": [
"MERGED",
"SUPERSEDED",
"OPEN",
"DECLINED"
],
"in": "query",
"type": "string"
"items": {
"enum": [
"MERGED",
"SUPERSEDED",
"OPEN",
"DECLINED"
],
"type": "string"
},
"in": "query",
"type": "array"
},
"username": {
"in": "path",
Expand Down
7 changes: 7 additions & 0 deletions src/utils/__tests__/add-query-parameters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ describe('utils:add-query-parameters', () => {
})
expect(qs).toMatchSnapshot()
})

it('accepts array for state, so it can return all pull requests', () => {
let state = addQueryParameters(url, {
state: ['MERGED', 'OPEN']
})
expect(state).toBe('/?state=MERGED&state=OPEN')
})
})
7 changes: 7 additions & 0 deletions src/utils/add-query-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @param {Object} params - Query Parameters
* @returns {String} URL with added Query Parameters
*/
const qs = require('qs')

const addQueryParameters = (url, params = {}) => {
const separator = /\?/.test(url) ? '&' : '?'
const names = Object.keys(params)
Expand All @@ -25,6 +27,11 @@ const addQueryParameters = (url, params = {}) => {
)
.join('+')}`
}
if (name === 'state') {
if (Array.isArray(params.state)) {
return `${qs.stringify({ state: params.state }, { arrayFormat: "repeat" })}`
}
}
return `${name}=${encodeURIComponent(params[name])}`
})
.join('&')}`
Expand Down