@atlassianlabs/jira-pi-client
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -1,2 +0,2 @@ | ||
import { CommentVisibility, Component, Filter, IssueLinkType, MinimalIssueLink, Project, User, Version, Votes, Watches } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { CommentVisibility, Component, Filter, FilterSearchResult, IssueLinkType, MinimalIssueLink, Project, User, Version, Votes, Watches } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { JiraSiteInfo } from '@atlassianlabs/jira-pi-common-models/JiraSiteInfo'; | ||
@@ -51,3 +51,3 @@ import { AutocompleteSuggestion, CreatedIssue, IssuePickerIssue, JQLAutocompleteData } from '@atlassianlabs/jira-pi-common-models/responses'; | ||
getFilter(filterId: string): Promise<Filter | undefined>; | ||
abstract searchFilters(query: string): Promise<Filter[]>; | ||
abstract searchFilters(query: string): Promise<FilterSearchResult[]>; | ||
searchForIssuesUsingJqlGet(jql: string, fields: string[], maxResults?: number, startAt?: number): Promise<any>; | ||
@@ -71,2 +71,3 @@ createVersion(params: any): Promise<Version>; | ||
protected getFromJira(url: string, queryParams?: any, cancelToken?: CancelToken): Promise<any>; | ||
protected getFromJiraCustomUrl(url: string, queryParams?: any, cancelToken?: CancelToken): Promise<any>; | ||
protected postToJira(url: string, params?: any, queryParams?: any): Promise<any>; | ||
@@ -73,0 +74,0 @@ protected multipartToJira(url: string, formData: FormData, queryParams?: any): Promise<any>; |
232
client.js
@@ -1196,11 +1196,11 @@ "use strict"; | ||
}, { | ||
key: "postToJira", | ||
value: function postToJira(url, params, queryParams) { | ||
var sp, _i2, _Object$entries2, _Object$entries2$_i, k, v, data, res; | ||
key: "getFromJiraCustomUrl", | ||
value: function getFromJiraCustomUrl(url, queryParams, cancelToken) { | ||
var sp, _i2, _Object$entries2, _Object$entries2$_i, k, v, res; | ||
return _regenerator["default"].async(function postToJira$(_context40) { | ||
return _regenerator["default"].async(function getFromJiraCustomUrl$(_context40) { | ||
while (1) { | ||
switch (_context40.prev = _context40.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
url = "".concat(this.baseUrl, "/").concat(url); | ||
@@ -1216,11 +1216,2 @@ if (queryParams) { | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} // yup, jira's silly and accepts post with no data | ||
data = {}; | ||
if (params) { | ||
data = { | ||
data: JSON.stringify(params) | ||
}; | ||
} | ||
@@ -1232,6 +1223,6 @@ | ||
_context40.t3 = _extends2["default"]; | ||
_context40.next = 10; | ||
return _regenerator["default"].awrap(this.authorizationProvider('POST', url)); | ||
_context40.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('GET', url)); | ||
case 10: | ||
case 8: | ||
_context40.t4 = _context40.sent; | ||
@@ -1242,19 +1233,19 @@ _context40.t5 = { | ||
}; | ||
_context40.t6 = { | ||
method: 'POST', | ||
headers: _context40.t5 | ||
_context40.t6 = cancelToken; | ||
_context40.t7 = { | ||
method: 'GET', | ||
headers: _context40.t5, | ||
cancelToken: _context40.t6 | ||
}; | ||
_context40.t7 = this.agent; | ||
_context40.t8 = {}; | ||
_context40.t9 = data; | ||
_context40.t10 = (0, _context40.t3)(_context40.t6, _context40.t7, _context40.t8, _context40.t9); | ||
_context40.t11 = (0, _context40.t1)(_context40.t2, _context40.t10); | ||
_context40.next = 20; | ||
return _context40.t0.awrap.call(_context40.t0, _context40.t11); | ||
_context40.t8 = this.agent; | ||
_context40.t9 = (0, _context40.t3)(_context40.t7, _context40.t8); | ||
_context40.t10 = (0, _context40.t1)(_context40.t2, _context40.t9); | ||
_context40.next = 17; | ||
return _context40.t0.awrap.call(_context40.t0, _context40.t10); | ||
case 20: | ||
case 17: | ||
res = _context40.sent; | ||
return _context40.abrupt("return", res.data); | ||
case 22: | ||
case 19: | ||
case "end": | ||
@@ -1267,7 +1258,7 @@ return _context40.stop(); | ||
}, { | ||
key: "multipartToJira", | ||
value: function multipartToJira(url, formData, queryParams) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, res; | ||
key: "postToJira", | ||
value: function postToJira(url, params, queryParams) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, data, res; | ||
return _regenerator["default"].async(function multipartToJira$(_context41) { | ||
return _regenerator["default"].async(function postToJira$(_context41) { | ||
while (1) { | ||
@@ -1287,2 +1278,11 @@ switch (_context41.prev = _context41.next) { | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} // yup, jira's silly and accepts post with no data | ||
data = {}; | ||
if (params) { | ||
data = { | ||
data: JSON.stringify(params) | ||
}; | ||
} | ||
@@ -1293,28 +1293,29 @@ | ||
_context41.t2 = url; | ||
_context41.t3 = formData; | ||
_context41.t4 = _extends2["default"]; | ||
_context41.next = 9; | ||
_context41.t3 = _extends2["default"]; | ||
_context41.next = 10; | ||
return _regenerator["default"].awrap(this.authorizationProvider('POST', url)); | ||
case 9: | ||
_context41.t5 = _context41.sent; | ||
_context41.t6 = formData.getHeaders()['content-type']; | ||
_context41.t7 = { | ||
Authorization: _context41.t5, | ||
'Content-Type': _context41.t6 | ||
case 10: | ||
_context41.t4 = _context41.sent; | ||
_context41.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context41.t4 | ||
}; | ||
_context41.t8 = { | ||
headers: _context41.t7 | ||
_context41.t6 = { | ||
method: 'POST', | ||
headers: _context41.t5 | ||
}; | ||
_context41.t9 = this.agent; | ||
_context41.t10 = (0, _context41.t4)(_context41.t8, _context41.t9); | ||
_context41.t11 = _context41.t1.post.call(_context41.t1, _context41.t2, _context41.t3, _context41.t10); | ||
_context41.next = 18; | ||
_context41.t7 = this.agent; | ||
_context41.t8 = {}; | ||
_context41.t9 = data; | ||
_context41.t10 = (0, _context41.t3)(_context41.t6, _context41.t7, _context41.t8, _context41.t9); | ||
_context41.t11 = (0, _context41.t1)(_context41.t2, _context41.t10); | ||
_context41.next = 20; | ||
return _context41.t0.awrap.call(_context41.t0, _context41.t11); | ||
case 18: | ||
case 20: | ||
res = _context41.sent; | ||
return _context41.abrupt("return", res.data); | ||
case 20: | ||
case 22: | ||
case "end": | ||
@@ -1327,7 +1328,7 @@ return _context41.stop(); | ||
}, { | ||
key: "putToJira", | ||
value: function putToJira(url, params, queryParams) { | ||
key: "multipartToJira", | ||
value: function multipartToJira(url, formData, queryParams) { | ||
var sp, _i4, _Object$entries4, _Object$entries4$_i, k, v, res; | ||
return _regenerator["default"].async(function putToJira$(_context42) { | ||
return _regenerator["default"].async(function multipartToJira$(_context42) { | ||
while (1) { | ||
@@ -1352,29 +1353,28 @@ switch (_context42.prev = _context42.next) { | ||
_context42.t2 = url; | ||
_context42.t3 = _extends2["default"]; | ||
_context42.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('PUT', url)); | ||
_context42.t3 = formData; | ||
_context42.t4 = _extends2["default"]; | ||
_context42.next = 9; | ||
return _regenerator["default"].awrap(this.authorizationProvider('POST', url)); | ||
case 8: | ||
_context42.t4 = _context42.sent; | ||
_context42.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context42.t4 | ||
}; | ||
_context42.t6 = JSON.stringify(params); | ||
case 9: | ||
_context42.t5 = _context42.sent; | ||
_context42.t6 = formData.getHeaders()['content-type']; | ||
_context42.t7 = { | ||
method: 'PUT', | ||
headers: _context42.t5, | ||
data: _context42.t6 | ||
Authorization: _context42.t5, | ||
'Content-Type': _context42.t6 | ||
}; | ||
_context42.t8 = this.agent; | ||
_context42.t9 = (0, _context42.t3)(_context42.t7, _context42.t8); | ||
_context42.t10 = (0, _context42.t1)(_context42.t2, _context42.t9); | ||
_context42.next = 17; | ||
return _context42.t0.awrap.call(_context42.t0, _context42.t10); | ||
_context42.t8 = { | ||
headers: _context42.t7 | ||
}; | ||
_context42.t9 = this.agent; | ||
_context42.t10 = (0, _context42.t4)(_context42.t8, _context42.t9); | ||
_context42.t11 = _context42.t1.post.call(_context42.t1, _context42.t2, _context42.t3, _context42.t10); | ||
_context42.next = 18; | ||
return _context42.t0.awrap.call(_context42.t0, _context42.t11); | ||
case 17: | ||
case 18: | ||
res = _context42.sent; | ||
return _context42.abrupt("return", res.data); | ||
case 19: | ||
case 20: | ||
case "end": | ||
@@ -1387,7 +1387,7 @@ return _context42.stop(); | ||
}, { | ||
key: "deleteToJira", | ||
value: function deleteToJira(url, queryParams) { | ||
key: "putToJira", | ||
value: function putToJira(url, params, queryParams) { | ||
var sp, _i5, _Object$entries5, _Object$entries5$_i, k, v, res; | ||
return _regenerator["default"].async(function deleteToJira$(_context43) { | ||
return _regenerator["default"].async(function putToJira$(_context43) { | ||
while (1) { | ||
@@ -1414,3 +1414,3 @@ switch (_context43.prev = _context43.next) { | ||
_context43.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('DELETE', url)); | ||
return _regenerator["default"].awrap(this.authorizationProvider('PUT', url)); | ||
@@ -1423,17 +1423,19 @@ case 8: | ||
}; | ||
_context43.t6 = { | ||
method: 'DELETE', | ||
headers: _context43.t5 | ||
_context43.t6 = JSON.stringify(params); | ||
_context43.t7 = { | ||
method: 'PUT', | ||
headers: _context43.t5, | ||
data: _context43.t6 | ||
}; | ||
_context43.t7 = this.agent; | ||
_context43.t8 = (0, _context43.t3)(_context43.t6, _context43.t7); | ||
_context43.t9 = (0, _context43.t1)(_context43.t2, _context43.t8); | ||
_context43.next = 16; | ||
return _context43.t0.awrap.call(_context43.t0, _context43.t9); | ||
_context43.t8 = this.agent; | ||
_context43.t9 = (0, _context43.t3)(_context43.t7, _context43.t8); | ||
_context43.t10 = (0, _context43.t1)(_context43.t2, _context43.t9); | ||
_context43.next = 17; | ||
return _context43.t0.awrap.call(_context43.t0, _context43.t10); | ||
case 16: | ||
case 17: | ||
res = _context43.sent; | ||
return _context43.abrupt("return", res.data); | ||
case 18: | ||
case 19: | ||
case "end": | ||
@@ -1445,2 +1447,58 @@ return _context43.stop(); | ||
} | ||
}, { | ||
key: "deleteToJira", | ||
value: function deleteToJira(url, queryParams) { | ||
var sp, _i6, _Object$entries6, _Object$entries6$_i, k, v, res; | ||
return _regenerator["default"].async(function deleteToJira$(_context44) { | ||
while (1) { | ||
switch (_context44.prev = _context44.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
if (queryParams) { | ||
sp = new URLSearchParams(); | ||
for (_i6 = 0, _Object$entries6 = Object.entries(queryParams); _i6 < _Object$entries6.length; _i6++) { | ||
_Object$entries6$_i = (0, _slicedToArray2["default"])(_Object$entries6[_i6], 2), k = _Object$entries6$_i[0], v = _Object$entries6$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
} | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} | ||
_context44.t0 = _regenerator["default"]; | ||
_context44.t1 = this.transportFactory(); | ||
_context44.t2 = url; | ||
_context44.t3 = _extends2["default"]; | ||
_context44.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('DELETE', url)); | ||
case 8: | ||
_context44.t4 = _context44.sent; | ||
_context44.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context44.t4 | ||
}; | ||
_context44.t6 = { | ||
method: 'DELETE', | ||
headers: _context44.t5 | ||
}; | ||
_context44.t7 = this.agent; | ||
_context44.t8 = (0, _context44.t3)(_context44.t6, _context44.t7); | ||
_context44.t9 = (0, _context44.t1)(_context44.t2, _context44.t8); | ||
_context44.next = 16; | ||
return _context44.t0.awrap.call(_context44.t0, _context44.t9); | ||
case 16: | ||
res = _context44.sent; | ||
return _context44.abrupt("return", res.data); | ||
case 18: | ||
case "end": | ||
return _context44.stop(); | ||
} | ||
} | ||
}, null, this); | ||
} | ||
}]); | ||
@@ -1447,0 +1505,0 @@ return JiraClient; |
@@ -1,2 +0,2 @@ | ||
import { Filter, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { FilterSearchResult, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { JiraSiteInfo } from '@atlassianlabs/jira-pi-common-models/JiraSiteInfo'; | ||
@@ -9,3 +9,3 @@ import { AgentProvider } from '@atlassianlabs/pi-client-common/agent'; | ||
getProjects(query?: string, orderBy?: string): Promise<Project[]>; | ||
searchFilters(query: string): Promise<Filter[]>; | ||
searchFilters(query: string): Promise<FilterSearchResult[]>; | ||
} |
@@ -108,3 +108,3 @@ "use strict"; | ||
value: function searchFilters(query) { | ||
var res; | ||
var res, results; | ||
return _regenerator["default"].async(function searchFilters$(_context3) { | ||
@@ -116,5 +116,4 @@ while (1) { | ||
return _regenerator["default"].awrap(this.getFromJira('filter/search', { | ||
expand: 'jql,favourite', | ||
expand: 'favourite,owner,jql,viewUrl', | ||
filterName: query, | ||
maxResults: 25, | ||
orderBy: '+NAME' | ||
@@ -125,20 +124,19 @@ })); | ||
res = _context3.sent; | ||
results = []; | ||
if (!Array.isArray(res.values)) { | ||
_context3.next = 5; | ||
break; | ||
if (Array.isArray(res.values)) { | ||
results = res.values.map(function (f) { | ||
return { | ||
id: f.id, | ||
name: f.name, | ||
jql: f.jql, | ||
favorite: f.favourite, | ||
owner: f.owner.displayName, | ||
viewUrlPath: "/issues/?filter=".concat(f.id) | ||
}; | ||
}); | ||
} | ||
return _context3.abrupt("return", res.values.map(function (f) { | ||
return { | ||
id: f.id, | ||
name: f.name, | ||
jql: f.jql, | ||
favorite: f.favourite | ||
}; | ||
})); | ||
return _context3.abrupt("return", results); | ||
case 5: | ||
return _context3.abrupt("return", []); | ||
case 6: | ||
@@ -145,0 +143,0 @@ case "end": |
@@ -1175,11 +1175,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
}, { | ||
key: "postToJira", | ||
value: function postToJira(url, params, queryParams) { | ||
var sp, _i2, _Object$entries2, _Object$entries2$_i, k, v, data, res; | ||
key: "getFromJiraCustomUrl", | ||
value: function getFromJiraCustomUrl(url, queryParams, cancelToken) { | ||
var sp, _i2, _Object$entries2, _Object$entries2$_i, k, v, res; | ||
return _regeneratorRuntime.async(function postToJira$(_context40) { | ||
return _regeneratorRuntime.async(function getFromJiraCustomUrl$(_context40) { | ||
while (1) { | ||
switch (_context40.prev = _context40.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
url = "".concat(this.baseUrl, "/").concat(url); | ||
@@ -1195,11 +1195,2 @@ if (queryParams) { | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} // yup, jira's silly and accepts post with no data | ||
data = {}; | ||
if (params) { | ||
data = { | ||
data: JSON.stringify(params) | ||
}; | ||
} | ||
@@ -1211,6 +1202,6 @@ | ||
_context40.t3 = _extends; | ||
_context40.next = 10; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('POST', url)); | ||
_context40.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('GET', url)); | ||
case 10: | ||
case 8: | ||
_context40.t4 = _context40.sent; | ||
@@ -1221,19 +1212,19 @@ _context40.t5 = { | ||
}; | ||
_context40.t6 = { | ||
method: 'POST', | ||
headers: _context40.t5 | ||
_context40.t6 = cancelToken; | ||
_context40.t7 = { | ||
method: 'GET', | ||
headers: _context40.t5, | ||
cancelToken: _context40.t6 | ||
}; | ||
_context40.t7 = this.agent; | ||
_context40.t8 = {}; | ||
_context40.t9 = data; | ||
_context40.t10 = (0, _context40.t3)(_context40.t6, _context40.t7, _context40.t8, _context40.t9); | ||
_context40.t11 = (0, _context40.t1)(_context40.t2, _context40.t10); | ||
_context40.next = 20; | ||
return _context40.t0.awrap.call(_context40.t0, _context40.t11); | ||
_context40.t8 = this.agent; | ||
_context40.t9 = (0, _context40.t3)(_context40.t7, _context40.t8); | ||
_context40.t10 = (0, _context40.t1)(_context40.t2, _context40.t9); | ||
_context40.next = 17; | ||
return _context40.t0.awrap.call(_context40.t0, _context40.t10); | ||
case 20: | ||
case 17: | ||
res = _context40.sent; | ||
return _context40.abrupt("return", res.data); | ||
case 22: | ||
case 19: | ||
case "end": | ||
@@ -1246,7 +1237,7 @@ return _context40.stop(); | ||
}, { | ||
key: "multipartToJira", | ||
value: function multipartToJira(url, formData, queryParams) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, res; | ||
key: "postToJira", | ||
value: function postToJira(url, params, queryParams) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, data, res; | ||
return _regeneratorRuntime.async(function multipartToJira$(_context41) { | ||
return _regeneratorRuntime.async(function postToJira$(_context41) { | ||
while (1) { | ||
@@ -1266,2 +1257,11 @@ switch (_context41.prev = _context41.next) { | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} // yup, jira's silly and accepts post with no data | ||
data = {}; | ||
if (params) { | ||
data = { | ||
data: JSON.stringify(params) | ||
}; | ||
} | ||
@@ -1272,28 +1272,29 @@ | ||
_context41.t2 = url; | ||
_context41.t3 = formData; | ||
_context41.t4 = _extends; | ||
_context41.next = 9; | ||
_context41.t3 = _extends; | ||
_context41.next = 10; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('POST', url)); | ||
case 9: | ||
_context41.t5 = _context41.sent; | ||
_context41.t6 = formData.getHeaders()['content-type']; | ||
_context41.t7 = { | ||
Authorization: _context41.t5, | ||
'Content-Type': _context41.t6 | ||
case 10: | ||
_context41.t4 = _context41.sent; | ||
_context41.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context41.t4 | ||
}; | ||
_context41.t8 = { | ||
headers: _context41.t7 | ||
_context41.t6 = { | ||
method: 'POST', | ||
headers: _context41.t5 | ||
}; | ||
_context41.t9 = this.agent; | ||
_context41.t10 = (0, _context41.t4)(_context41.t8, _context41.t9); | ||
_context41.t11 = _context41.t1.post.call(_context41.t1, _context41.t2, _context41.t3, _context41.t10); | ||
_context41.next = 18; | ||
_context41.t7 = this.agent; | ||
_context41.t8 = {}; | ||
_context41.t9 = data; | ||
_context41.t10 = (0, _context41.t3)(_context41.t6, _context41.t7, _context41.t8, _context41.t9); | ||
_context41.t11 = (0, _context41.t1)(_context41.t2, _context41.t10); | ||
_context41.next = 20; | ||
return _context41.t0.awrap.call(_context41.t0, _context41.t11); | ||
case 18: | ||
case 20: | ||
res = _context41.sent; | ||
return _context41.abrupt("return", res.data); | ||
case 20: | ||
case 22: | ||
case "end": | ||
@@ -1306,7 +1307,7 @@ return _context41.stop(); | ||
}, { | ||
key: "putToJira", | ||
value: function putToJira(url, params, queryParams) { | ||
key: "multipartToJira", | ||
value: function multipartToJira(url, formData, queryParams) { | ||
var sp, _i4, _Object$entries4, _Object$entries4$_i, k, v, res; | ||
return _regeneratorRuntime.async(function putToJira$(_context42) { | ||
return _regeneratorRuntime.async(function multipartToJira$(_context42) { | ||
while (1) { | ||
@@ -1331,29 +1332,28 @@ switch (_context42.prev = _context42.next) { | ||
_context42.t2 = url; | ||
_context42.t3 = _extends; | ||
_context42.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('PUT', url)); | ||
_context42.t3 = formData; | ||
_context42.t4 = _extends; | ||
_context42.next = 9; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('POST', url)); | ||
case 8: | ||
_context42.t4 = _context42.sent; | ||
_context42.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context42.t4 | ||
}; | ||
_context42.t6 = JSON.stringify(params); | ||
case 9: | ||
_context42.t5 = _context42.sent; | ||
_context42.t6 = formData.getHeaders()['content-type']; | ||
_context42.t7 = { | ||
method: 'PUT', | ||
headers: _context42.t5, | ||
data: _context42.t6 | ||
Authorization: _context42.t5, | ||
'Content-Type': _context42.t6 | ||
}; | ||
_context42.t8 = this.agent; | ||
_context42.t9 = (0, _context42.t3)(_context42.t7, _context42.t8); | ||
_context42.t10 = (0, _context42.t1)(_context42.t2, _context42.t9); | ||
_context42.next = 17; | ||
return _context42.t0.awrap.call(_context42.t0, _context42.t10); | ||
_context42.t8 = { | ||
headers: _context42.t7 | ||
}; | ||
_context42.t9 = this.agent; | ||
_context42.t10 = (0, _context42.t4)(_context42.t8, _context42.t9); | ||
_context42.t11 = _context42.t1.post.call(_context42.t1, _context42.t2, _context42.t3, _context42.t10); | ||
_context42.next = 18; | ||
return _context42.t0.awrap.call(_context42.t0, _context42.t11); | ||
case 17: | ||
case 18: | ||
res = _context42.sent; | ||
return _context42.abrupt("return", res.data); | ||
case 19: | ||
case 20: | ||
case "end": | ||
@@ -1366,7 +1366,7 @@ return _context42.stop(); | ||
}, { | ||
key: "deleteToJira", | ||
value: function deleteToJira(url, queryParams) { | ||
key: "putToJira", | ||
value: function putToJira(url, params, queryParams) { | ||
var sp, _i5, _Object$entries5, _Object$entries5$_i, k, v, res; | ||
return _regeneratorRuntime.async(function deleteToJira$(_context43) { | ||
return _regeneratorRuntime.async(function putToJira$(_context43) { | ||
while (1) { | ||
@@ -1393,3 +1393,3 @@ switch (_context43.prev = _context43.next) { | ||
_context43.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('DELETE', url)); | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('PUT', url)); | ||
@@ -1402,17 +1402,19 @@ case 8: | ||
}; | ||
_context43.t6 = { | ||
method: 'DELETE', | ||
headers: _context43.t5 | ||
_context43.t6 = JSON.stringify(params); | ||
_context43.t7 = { | ||
method: 'PUT', | ||
headers: _context43.t5, | ||
data: _context43.t6 | ||
}; | ||
_context43.t7 = this.agent; | ||
_context43.t8 = (0, _context43.t3)(_context43.t6, _context43.t7); | ||
_context43.t9 = (0, _context43.t1)(_context43.t2, _context43.t8); | ||
_context43.next = 16; | ||
return _context43.t0.awrap.call(_context43.t0, _context43.t9); | ||
_context43.t8 = this.agent; | ||
_context43.t9 = (0, _context43.t3)(_context43.t7, _context43.t8); | ||
_context43.t10 = (0, _context43.t1)(_context43.t2, _context43.t9); | ||
_context43.next = 17; | ||
return _context43.t0.awrap.call(_context43.t0, _context43.t10); | ||
case 16: | ||
case 17: | ||
res = _context43.sent; | ||
return _context43.abrupt("return", res.data); | ||
case 18: | ||
case 19: | ||
case "end": | ||
@@ -1424,2 +1426,58 @@ return _context43.stop(); | ||
} | ||
}, { | ||
key: "deleteToJira", | ||
value: function deleteToJira(url, queryParams) { | ||
var sp, _i6, _Object$entries6, _Object$entries6$_i, k, v, res; | ||
return _regeneratorRuntime.async(function deleteToJira$(_context44) { | ||
while (1) { | ||
switch (_context44.prev = _context44.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
if (queryParams) { | ||
sp = new URLSearchParams(); | ||
for (_i6 = 0, _Object$entries6 = Object.entries(queryParams); _i6 < _Object$entries6.length; _i6++) { | ||
_Object$entries6$_i = _slicedToArray(_Object$entries6[_i6], 2), k = _Object$entries6$_i[0], v = _Object$entries6$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
} | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} | ||
_context44.t0 = _regeneratorRuntime; | ||
_context44.t1 = this.transportFactory(); | ||
_context44.t2 = url; | ||
_context44.t3 = _extends; | ||
_context44.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('DELETE', url)); | ||
case 8: | ||
_context44.t4 = _context44.sent; | ||
_context44.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context44.t4 | ||
}; | ||
_context44.t6 = { | ||
method: 'DELETE', | ||
headers: _context44.t5 | ||
}; | ||
_context44.t7 = this.agent; | ||
_context44.t8 = (0, _context44.t3)(_context44.t6, _context44.t7); | ||
_context44.t9 = (0, _context44.t1)(_context44.t2, _context44.t8); | ||
_context44.next = 16; | ||
return _context44.t0.awrap.call(_context44.t0, _context44.t9); | ||
case 16: | ||
res = _context44.sent; | ||
return _context44.abrupt("return", res.data); | ||
case 18: | ||
case "end": | ||
return _context44.stop(); | ||
} | ||
} | ||
}, null, this); | ||
} | ||
}]); | ||
@@ -1426,0 +1484,0 @@ |
@@ -92,3 +92,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
value: function searchFilters(query) { | ||
var res; | ||
var res, results; | ||
return _regeneratorRuntime.async(function searchFilters$(_context3) { | ||
@@ -100,5 +100,4 @@ while (1) { | ||
return _regeneratorRuntime.awrap(this.getFromJira('filter/search', { | ||
expand: 'jql,favourite', | ||
expand: 'favourite,owner,jql,viewUrl', | ||
filterName: query, | ||
maxResults: 25, | ||
orderBy: '+NAME' | ||
@@ -109,20 +108,19 @@ })); | ||
res = _context3.sent; | ||
results = []; | ||
if (!Array.isArray(res.values)) { | ||
_context3.next = 5; | ||
break; | ||
if (Array.isArray(res.values)) { | ||
results = res.values.map(function (f) { | ||
return { | ||
id: f.id, | ||
name: f.name, | ||
jql: f.jql, | ||
favorite: f.favourite, | ||
owner: f.owner.displayName, | ||
viewUrlPath: "/issues/?filter=".concat(f.id) | ||
}; | ||
}); | ||
} | ||
return _context3.abrupt("return", res.values.map(function (f) { | ||
return { | ||
id: f.id, | ||
name: f.name, | ||
jql: f.jql, | ||
favorite: f.favourite | ||
}; | ||
})); | ||
return _context3.abrupt("return", results); | ||
case 5: | ||
return _context3.abrupt("return", []); | ||
case 6: | ||
@@ -129,0 +127,0 @@ case "end": |
@@ -93,2 +93,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
value: function searchFilters(query) { | ||
var res, favIds, favRes, results; | ||
return _regeneratorRuntime.async(function searchFilters$(_context3) { | ||
@@ -98,5 +99,40 @@ while (1) { | ||
case 0: | ||
return _context3.abrupt("return", []); | ||
_context3.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJiraCustomUrl('greenhopper/1.0/savedfilter/list', { | ||
query: query | ||
})); | ||
case 1: | ||
case 2: | ||
res = _context3.sent; | ||
favIds = []; | ||
_context3.next = 6; | ||
return _regeneratorRuntime.awrap(this.getFromJira('filter/favourite')); | ||
case 6: | ||
favRes = _context3.sent; | ||
if (Array.isArray(favRes)) { | ||
favIds = favRes.map(function (fav) { | ||
return fav.id; | ||
}); | ||
} | ||
results = []; | ||
if (Array.isArray(res.filters)) { | ||
results = res.filters.map(function (f) { | ||
return { | ||
id: f.id, | ||
name: f.name, | ||
jql: f.query, | ||
favorite: favIds.includes(f.id), | ||
owner: f.owner.displayName, | ||
viewUrlPath: "/issues/?filter=".concat(f.id) | ||
}; | ||
}); | ||
} | ||
return _context3.abrupt("return", results); | ||
case 11: | ||
case "end": | ||
@@ -106,3 +142,3 @@ return _context3.stop(); | ||
} | ||
}); | ||
}, null, this); | ||
} | ||
@@ -109,0 +145,0 @@ }]); |
{ | ||
"name": "@atlassianlabs/jira-pi-client", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "Transform jira meta information to a ui descriptor", | ||
@@ -15,4 +15,4 @@ "repository": { | ||
"dependencies": { | ||
"@atlassianlabs/jira-pi-common-models": "^0.1.14", | ||
"@atlassianlabs/jira-pi-meta-models": "^0.1.14", | ||
"@atlassianlabs/jira-pi-common-models": "^0.1.15", | ||
"@atlassianlabs/jira-pi-meta-models": "^0.1.15", | ||
"@atlassianlabs/pi-client-common": "^0.1.14" | ||
@@ -24,5 +24,5 @@ }, | ||
}, | ||
"gitHead": "57a0be91795888a72d1139123153d3091721965a", | ||
"gitHead": "49bda0d84dde41e1f01e6be649cd6513ead7a752", | ||
"main": "./index.js", | ||
"typings": "./index.d.ts" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Filter, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { FilterSearchResult, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { JiraSiteInfo } from '@atlassianlabs/jira-pi-common-models/JiraSiteInfo'; | ||
@@ -9,4 +9,4 @@ import { AgentProvider } from '@atlassianlabs/pi-client-common/agent'; | ||
getProjects(query?: string, orderBy?: string): Promise<Project[]>; | ||
searchFilters(query: string): Promise<Filter[]>; | ||
searchFilters(query: string): Promise<FilterSearchResult[]>; | ||
} | ||
export declare function defaultJiraServerClient<S extends JiraSiteInfo>(site: S, username: string, password: string): JiraServerClient<S>; |
@@ -111,2 +111,3 @@ "use strict"; | ||
value: function searchFilters(query) { | ||
var res, favIds, favRes, results; | ||
return _regenerator["default"].async(function searchFilters$(_context3) { | ||
@@ -116,5 +117,40 @@ while (1) { | ||
case 0: | ||
return _context3.abrupt("return", []); | ||
_context3.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJiraCustomUrl('greenhopper/1.0/savedfilter/list', { | ||
query: query | ||
})); | ||
case 1: | ||
case 2: | ||
res = _context3.sent; | ||
favIds = []; | ||
_context3.next = 6; | ||
return _regenerator["default"].awrap(this.getFromJira('filter/favourite')); | ||
case 6: | ||
favRes = _context3.sent; | ||
if (Array.isArray(favRes)) { | ||
favIds = favRes.map(function (fav) { | ||
return fav.id; | ||
}); | ||
} | ||
results = []; | ||
if (Array.isArray(res.filters)) { | ||
results = res.filters.map(function (f) { | ||
return { | ||
id: f.id, | ||
name: f.name, | ||
jql: f.query, | ||
favorite: favIds.includes(f.id), | ||
owner: f.owner.displayName, | ||
viewUrlPath: "/issues/?filter=".concat(f.id) | ||
}; | ||
}); | ||
} | ||
return _context3.abrupt("return", results); | ||
case 11: | ||
case "end": | ||
@@ -124,3 +160,3 @@ return _context3.stop(); | ||
} | ||
}); | ||
}, null, this); | ||
} | ||
@@ -127,0 +163,0 @@ }]); |
127423
3269