@atlassianlabs/jira-pi-client
Advanced tools
Comparing version 0.1.14 to 0.1.15-links
@@ -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, FilterSearchResults, IssueLinkType, JQLErrors, MinimalIssueLink, Project, User, Version, Votes, Watches } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { JiraSiteInfo } from '@atlassianlabs/jira-pi-common-models/JiraSiteInfo'; | ||
@@ -48,6 +48,7 @@ import { AutocompleteSuggestion, CreatedIssue, IssuePickerIssue, JQLAutocompleteData } from '@atlassianlabs/jira-pi-common-models/responses'; | ||
getJQLAutocompleteData(cancelToken?: CancelToken): Promise<JQLAutocompleteData>; | ||
validateJql(jql: string, cancelToken?: CancelToken): Promise<JQLErrors>; | ||
getFavoriteFilters(): Promise<Filter[]>; | ||
getMyFilters(): Promise<Filter[]>; | ||
getFilter(filterId: string): Promise<Filter | undefined>; | ||
abstract searchFilters(query: string): Promise<Filter[]>; | ||
abstract searchFilters(query: string, maxResults?: number, startAt?: number, cancelToken?: CancelToken): Promise<FilterSearchResults>; | ||
searchForIssuesUsingJqlGet(jql: string, fields: string[], maxResults?: number, startAt?: number): Promise<any>; | ||
@@ -71,3 +72,4 @@ createVersion(params: any): Promise<Version>; | ||
protected getFromJira(url: string, queryParams?: any, cancelToken?: CancelToken): Promise<any>; | ||
protected postToJira(url: string, params?: any, queryParams?: any): Promise<any>; | ||
protected getFromJiraCustomUrl(url: string, queryParams?: any, cancelToken?: CancelToken): Promise<any>; | ||
protected postToJira(url: string, params?: any, queryParams?: any, cancelToken?: CancelToken): Promise<any>; | ||
protected multipartToJira(url: string, formData: FormData, queryParams?: any): Promise<any>; | ||
@@ -74,0 +76,0 @@ protected putToJira(url: string, params: any, queryParams?: any): Promise<any>; |
592
client.js
@@ -634,2 +634,28 @@ "use strict"; | ||
}, null, this); | ||
} | ||
}, { | ||
key: "validateJql", | ||
value: function validateJql(jql, cancelToken) { | ||
var res; | ||
return _regenerator["default"].async(function validateJql$(_context19) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
_context19.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira('jql/parse', { | ||
queries: [jql] | ||
}, cancelToken)); | ||
case 2: | ||
res = _context19.sent; | ||
return _context19.abrupt("return", { | ||
errors: res.data && Array.isArray(res.data.errors) ? res.data.errors : [] | ||
}); | ||
case 4: | ||
case "end": | ||
return _context19.stop(); | ||
} | ||
} | ||
}, null, this); | ||
} // Filters | ||
@@ -641,25 +667,25 @@ | ||
var res; | ||
return _regenerator["default"].async(function getFavoriteFilters$(_context19) { | ||
return _regenerator["default"].async(function getFavoriteFilters$(_context20) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
_context19.next = 2; | ||
_context20.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira('filter/favourite')); | ||
case 2: | ||
res = _context19.sent; | ||
res = _context20.sent; | ||
if (!Array.isArray(res)) { | ||
_context19.next = 5; | ||
_context20.next = 5; | ||
break; | ||
} | ||
return _context19.abrupt("return", res); | ||
return _context20.abrupt("return", res); | ||
case 5: | ||
return _context19.abrupt("return", []); | ||
return _context20.abrupt("return", []); | ||
case 6: | ||
case "end": | ||
return _context19.stop(); | ||
return _context20.stop(); | ||
} | ||
@@ -673,25 +699,25 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getMyFilters$(_context20) { | ||
return _regenerator["default"].async(function getMyFilters$(_context21) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
_context20.next = 2; | ||
_context21.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira('filter/my')); | ||
case 2: | ||
res = _context20.sent; | ||
res = _context21.sent; | ||
if (!Array.isArray(res)) { | ||
_context20.next = 5; | ||
_context21.next = 5; | ||
break; | ||
} | ||
return _context20.abrupt("return", res); | ||
return _context21.abrupt("return", res); | ||
case 5: | ||
return _context20.abrupt("return", []); | ||
return _context21.abrupt("return", []); | ||
case 6: | ||
case "end": | ||
return _context20.stop(); | ||
return _context21.stop(); | ||
} | ||
@@ -705,7 +731,7 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getFilter$(_context21) { | ||
return _regenerator["default"].async(function getFilter$(_context22) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
_context21.next = 2; | ||
_context22.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira("filter/".concat(filterId), { | ||
@@ -716,17 +742,17 @@ expand: 'jql,favourite' | ||
case 2: | ||
res = _context21.sent; | ||
res = _context22.sent; | ||
if (!res) { | ||
_context21.next = 5; | ||
_context22.next = 5; | ||
break; | ||
} | ||
return _context21.abrupt("return", res); | ||
return _context22.abrupt("return", res); | ||
case 5: | ||
return _context21.abrupt("return", undefined); | ||
return _context22.abrupt("return", undefined); | ||
case 6: | ||
case "end": | ||
return _context21.stop(); | ||
return _context22.stop(); | ||
} | ||
@@ -743,16 +769,16 @@ } | ||
var res; | ||
return _regenerator["default"].async(function searchForIssuesUsingJqlGet$(_context22) { | ||
return _regenerator["default"].async(function searchForIssuesUsingJqlGet$(_context23) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
_context22.next = 2; | ||
_context23.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira('search', getSearchProps(jql, fields, maxResults, startAt))); | ||
case 2: | ||
res = _context22.sent; | ||
return _context22.abrupt("return", res); | ||
res = _context23.sent; | ||
return _context23.abrupt("return", res); | ||
case 4: | ||
case "end": | ||
return _context22.stop(); | ||
return _context23.stop(); | ||
} | ||
@@ -768,16 +794,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function createVersion$(_context23) { | ||
return _regenerator["default"].async(function createVersion$(_context24) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
_context23.next = 2; | ||
_context24.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira('version', params)); | ||
case 2: | ||
result = _context23.sent; | ||
return _context23.abrupt("return", (0, _entities.readVersion)(result)); | ||
result = _context24.sent; | ||
return _context24.abrupt("return", (0, _entities.readVersion)(result)); | ||
case 4: | ||
case "end": | ||
return _context23.stop(); | ||
return _context24.stop(); | ||
} | ||
@@ -792,16 +818,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function createComponent$(_context24) { | ||
return _regenerator["default"].async(function createComponent$(_context25) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context24.next = 2; | ||
_context25.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira('component', params)); | ||
case 2: | ||
result = _context24.sent; | ||
return _context24.abrupt("return", (0, _entities.readComponent)(result)); | ||
result = _context25.sent; | ||
return _context25.abrupt("return", (0, _entities.readComponent)(result)); | ||
case 4: | ||
case "end": | ||
return _context24.stop(); | ||
return _context25.stop(); | ||
} | ||
@@ -816,11 +842,11 @@ } | ||
var resp; | ||
return _regenerator["default"].async(function createIssueLink$(_context25) { | ||
return _regenerator["default"].async(function createIssueLink$(_context26) { | ||
while (1) { | ||
switch (_context25.prev = _context25.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context25.next = 2; | ||
_context26.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira('issueLink', linkData)); | ||
case 2: | ||
_context25.next = 4; | ||
_context26.next = 4; | ||
return _regenerator["default"].awrap(this.getFromJira("issue/".concat(parentIssueKey), { | ||
@@ -831,8 +857,8 @@ fields: 'issuelinks' | ||
case 4: | ||
resp = _context25.sent; | ||
return _context25.abrupt("return", (0, _entities.readMinimalIssueLinks)(resp.fields['issuelinks'], this.site)); | ||
resp = _context26.sent; | ||
return _context26.abrupt("return", (0, _entities.readMinimalIssueLinks)(resp.fields['issuelinks'], this.site)); | ||
case 6: | ||
case "end": | ||
return _context25.stop(); | ||
return _context26.stop(); | ||
} | ||
@@ -847,16 +873,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function addWorklog$(_context26) { | ||
return _regenerator["default"].async(function addWorklog$(_context27) { | ||
while (1) { | ||
switch (_context26.prev = _context26.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context26.next = 2; | ||
_context27.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira("issue/".concat(issuekey, "/worklog"), params, queryParams)); | ||
case 2: | ||
result = _context26.sent; | ||
return _context26.abrupt("return", result); | ||
result = _context27.sent; | ||
return _context27.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context26.stop(); | ||
return _context27.stop(); | ||
} | ||
@@ -871,16 +897,16 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getWatchers$(_context27) { | ||
return _regenerator["default"].async(function getWatchers$(_context28) { | ||
while (1) { | ||
switch (_context27.prev = _context27.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context27.next = 2; | ||
_context28.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira("issue/".concat(issueIdOrKey, "/watchers"))); | ||
case 2: | ||
res = _context27.sent; | ||
return _context27.abrupt("return", (0, _entities.readWatches)(res)); | ||
res = _context28.sent; | ||
return _context28.abrupt("return", (0, _entities.readWatches)(res)); | ||
case 4: | ||
case "end": | ||
return _context27.stop(); | ||
return _context28.stop(); | ||
} | ||
@@ -894,16 +920,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function addWatcher$(_context28) { | ||
return _regenerator["default"].async(function addWatcher$(_context29) { | ||
while (1) { | ||
switch (_context28.prev = _context28.next) { | ||
switch (_context29.prev = _context29.next) { | ||
case 0: | ||
_context28.next = 2; | ||
_context29.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira("issue/".concat(issuekey, "/watchers"), accountId)); | ||
case 2: | ||
result = _context28.sent; | ||
return _context28.abrupt("return", result); | ||
result = _context29.sent; | ||
return _context29.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context28.stop(); | ||
return _context29.stop(); | ||
} | ||
@@ -917,7 +943,7 @@ } | ||
var result; | ||
return _regenerator["default"].async(function removeWatcher$(_context29) { | ||
return _regenerator["default"].async(function removeWatcher$(_context30) { | ||
while (1) { | ||
switch (_context29.prev = _context29.next) { | ||
switch (_context30.prev = _context30.next) { | ||
case 0: | ||
_context29.next = 2; | ||
_context30.next = 2; | ||
return _regenerator["default"].awrap(this.deleteToJira("issue/".concat(issuekey, "/watchers"), { | ||
@@ -928,8 +954,8 @@ accountId: accountId | ||
case 2: | ||
result = _context29.sent; | ||
return _context29.abrupt("return", result); | ||
result = _context30.sent; | ||
return _context30.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context29.stop(); | ||
return _context30.stop(); | ||
} | ||
@@ -944,16 +970,16 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getVotes$(_context30) { | ||
return _regenerator["default"].async(function getVotes$(_context31) { | ||
while (1) { | ||
switch (_context30.prev = _context30.next) { | ||
switch (_context31.prev = _context31.next) { | ||
case 0: | ||
_context30.next = 2; | ||
_context31.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira("issue/".concat(issueIdOrKey, "/votes"))); | ||
case 2: | ||
res = _context30.sent; | ||
return _context30.abrupt("return", (0, _entities.readVotes)(res)); | ||
res = _context31.sent; | ||
return _context31.abrupt("return", (0, _entities.readVotes)(res)); | ||
case 4: | ||
case "end": | ||
return _context30.stop(); | ||
return _context31.stop(); | ||
} | ||
@@ -967,16 +993,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function addVote$(_context31) { | ||
return _regenerator["default"].async(function addVote$(_context32) { | ||
while (1) { | ||
switch (_context31.prev = _context31.next) { | ||
switch (_context32.prev = _context32.next) { | ||
case 0: | ||
_context31.next = 2; | ||
_context32.next = 2; | ||
return _regenerator["default"].awrap(this.postToJira("issue/".concat(issuekey, "/votes"))); | ||
case 2: | ||
result = _context31.sent; | ||
return _context31.abrupt("return", result); | ||
result = _context32.sent; | ||
return _context32.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context31.stop(); | ||
return _context32.stop(); | ||
} | ||
@@ -990,16 +1016,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function removeVote$(_context32) { | ||
return _regenerator["default"].async(function removeVote$(_context33) { | ||
while (1) { | ||
switch (_context32.prev = _context32.next) { | ||
switch (_context33.prev = _context33.next) { | ||
case 0: | ||
_context32.next = 2; | ||
_context33.next = 2; | ||
return _regenerator["default"].awrap(this.deleteToJira("issue/".concat(issuekey, "/votes"))); | ||
case 2: | ||
result = _context32.sent; | ||
return _context32.abrupt("return", result); | ||
result = _context33.sent; | ||
return _context33.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context32.stop(); | ||
return _context33.stop(); | ||
} | ||
@@ -1013,16 +1039,16 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getIssueLinkTypes$(_context33) { | ||
return _regenerator["default"].async(function getIssueLinkTypes$(_context34) { | ||
while (1) { | ||
switch (_context33.prev = _context33.next) { | ||
switch (_context34.prev = _context34.next) { | ||
case 0: | ||
_context33.next = 2; | ||
_context34.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira('issueLinkType')); | ||
case 2: | ||
res = _context33.sent; | ||
return _context33.abrupt("return", res.issueLinkTypes ? res.issueLinkTypes : []); | ||
res = _context34.sent; | ||
return _context34.abrupt("return", res.issueLinkTypes ? res.issueLinkTypes : []); | ||
case 4: | ||
case "end": | ||
return _context33.stop(); | ||
return _context34.stop(); | ||
} | ||
@@ -1037,18 +1063,18 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getFields$(_context34) { | ||
return _regenerator["default"].async(function getFields$(_context35) { | ||
while (1) { | ||
switch (_context34.prev = _context34.next) { | ||
switch (_context35.prev = _context35.next) { | ||
case 0: | ||
_context34.next = 2; | ||
_context35.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira('field')); | ||
case 2: | ||
res = _context34.sent; | ||
res = _context35.sent; | ||
if (!Array.isArray(res)) { | ||
_context34.next = 5; | ||
_context35.next = 5; | ||
break; | ||
} | ||
return _context34.abrupt("return", res.map(function (f) { | ||
return _context35.abrupt("return", res.map(function (f) { | ||
return (0, _fieldMetadata.readField)(f); | ||
@@ -1058,7 +1084,7 @@ })); | ||
case 5: | ||
return _context34.abrupt("return", []); | ||
return _context35.abrupt("return", []); | ||
case 6: | ||
case "end": | ||
return _context34.stop(); | ||
return _context35.stop(); | ||
} | ||
@@ -1073,16 +1099,16 @@ } | ||
var res; | ||
return _regenerator["default"].async(function getCurrentUser$(_context35) { | ||
return _regenerator["default"].async(function getCurrentUser$(_context36) { | ||
while (1) { | ||
switch (_context35.prev = _context35.next) { | ||
switch (_context36.prev = _context36.next) { | ||
case 0: | ||
_context35.next = 2; | ||
_context36.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJira('myself')); | ||
case 2: | ||
res = _context35.sent; | ||
return _context35.abrupt("return", res); | ||
res = _context36.sent; | ||
return _context36.abrupt("return", res); | ||
case 4: | ||
case "end": | ||
return _context35.stop(); | ||
return _context36.stop(); | ||
} | ||
@@ -1097,16 +1123,16 @@ } | ||
var res; | ||
return _regenerator["default"].async(function addAttachments$(_context36) { | ||
return _regenerator["default"].async(function addAttachments$(_context37) { | ||
while (1) { | ||
switch (_context36.prev = _context36.next) { | ||
switch (_context37.prev = _context37.next) { | ||
case 0: | ||
_context36.next = 2; | ||
_context37.next = 2; | ||
return _regenerator["default"].awrap(this.multipartToJira("issue/".concat(issuekey, "/attachments"), formData)); | ||
case 2: | ||
res = _context36.sent; | ||
return _context36.abrupt("return", res); | ||
res = _context37.sent; | ||
return _context37.abrupt("return", res); | ||
case 4: | ||
case "end": | ||
return _context36.stop(); | ||
return _context37.stop(); | ||
} | ||
@@ -1120,16 +1146,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function deleteAttachment$(_context37) { | ||
return _regenerator["default"].async(function deleteAttachment$(_context38) { | ||
while (1) { | ||
switch (_context37.prev = _context37.next) { | ||
switch (_context38.prev = _context38.next) { | ||
case 0: | ||
_context37.next = 2; | ||
_context38.next = 2; | ||
return _regenerator["default"].awrap(this.deleteToJira("attachment/".concat(attachmentId))); | ||
case 2: | ||
result = _context37.sent; | ||
return _context37.abrupt("return", result); | ||
result = _context38.sent; | ||
return _context38.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context37.stop(); | ||
return _context38.stop(); | ||
} | ||
@@ -1143,16 +1169,16 @@ } | ||
var result; | ||
return _regenerator["default"].async(function deleteIssuelink$(_context38) { | ||
return _regenerator["default"].async(function deleteIssuelink$(_context39) { | ||
while (1) { | ||
switch (_context38.prev = _context38.next) { | ||
switch (_context39.prev = _context39.next) { | ||
case 0: | ||
_context38.next = 2; | ||
_context39.next = 2; | ||
return _regenerator["default"].awrap(this.deleteToJira("issuelink/".concat(linkId))); | ||
case 2: | ||
result = _context38.sent; | ||
return _context38.abrupt("return", result); | ||
result = _context39.sent; | ||
return _context39.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context38.stop(); | ||
return _context39.stop(); | ||
} | ||
@@ -1167,5 +1193,5 @@ } | ||
return _regenerator["default"].async(function getFromJira$(_context39) { | ||
return _regenerator["default"].async(function getFromJira$(_context40) { | ||
while (1) { | ||
switch (_context39.prev = _context39.next) { | ||
switch (_context40.prev = _context40.next) { | ||
case 0: | ||
@@ -1185,34 +1211,34 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
_context39.t0 = _regenerator["default"]; | ||
_context39.t1 = this.transportFactory(); | ||
_context39.t2 = url; | ||
_context39.t3 = _extends2["default"]; | ||
_context39.next = 8; | ||
_context40.t0 = _regenerator["default"]; | ||
_context40.t1 = this.transportFactory(); | ||
_context40.t2 = url; | ||
_context40.t3 = _extends2["default"]; | ||
_context40.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('GET', url)); | ||
case 8: | ||
_context39.t4 = _context39.sent; | ||
_context39.t5 = { | ||
_context40.t4 = _context40.sent; | ||
_context40.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context39.t4 | ||
Authorization: _context40.t4 | ||
}; | ||
_context39.t6 = cancelToken; | ||
_context39.t7 = { | ||
_context40.t6 = cancelToken; | ||
_context40.t7 = { | ||
method: 'GET', | ||
headers: _context39.t5, | ||
cancelToken: _context39.t6 | ||
headers: _context40.t5, | ||
cancelToken: _context40.t6 | ||
}; | ||
_context39.t8 = this.agent; | ||
_context39.t9 = (0, _context39.t3)(_context39.t7, _context39.t8); | ||
_context39.t10 = (0, _context39.t1)(_context39.t2, _context39.t9); | ||
_context39.next = 17; | ||
return _context39.t0.awrap.call(_context39.t0, _context39.t10); | ||
_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 17: | ||
res = _context39.sent; | ||
return _context39.abrupt("return", res.data); | ||
res = _context40.sent; | ||
return _context40.abrupt("return", res.data); | ||
case 19: | ||
case "end": | ||
return _context39.stop(); | ||
return _context40.stop(); | ||
} | ||
@@ -1223,11 +1249,11 @@ } | ||
}, { | ||
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$(_context41) { | ||
while (1) { | ||
switch (_context40.prev = _context40.next) { | ||
switch (_context41.prev = _context41.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
url = "".concat(this.baseUrl, "/").concat(url); | ||
@@ -1243,2 +1269,60 @@ if (queryParams) { | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} | ||
_context41.t0 = _regenerator["default"]; | ||
_context41.t1 = this.transportFactory(); | ||
_context41.t2 = url; | ||
_context41.t3 = _extends2["default"]; | ||
_context41.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('GET', url)); | ||
case 8: | ||
_context41.t4 = _context41.sent; | ||
_context41.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context41.t4 | ||
}; | ||
_context41.t6 = cancelToken; | ||
_context41.t7 = { | ||
method: 'GET', | ||
headers: _context41.t5, | ||
cancelToken: _context41.t6 | ||
}; | ||
_context41.t8 = this.agent; | ||
_context41.t9 = (0, _context41.t3)(_context41.t7, _context41.t8); | ||
_context41.t10 = (0, _context41.t1)(_context41.t2, _context41.t9); | ||
_context41.next = 17; | ||
return _context41.t0.awrap.call(_context41.t0, _context41.t10); | ||
case 17: | ||
res = _context41.sent; | ||
return _context41.abrupt("return", res.data); | ||
case 19: | ||
case "end": | ||
return _context41.stop(); | ||
} | ||
} | ||
}, null, this); | ||
} | ||
}, { | ||
key: "postToJira", | ||
value: function postToJira(url, params, queryParams, cancelToken) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, data, res; | ||
return _regenerator["default"].async(function postToJira$(_context42) { | ||
while (1) { | ||
switch (_context42.prev = _context42.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
if (queryParams) { | ||
sp = new URLSearchParams(); | ||
for (_i3 = 0, _Object$entries3 = Object.entries(queryParams); _i3 < _Object$entries3.length; _i3++) { | ||
_Object$entries3$_i = (0, _slicedToArray2["default"])(_Object$entries3[_i3], 2), k = _Object$entries3$_i[0], v = _Object$entries3$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
} | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} // yup, jira's silly and accepts post with no data | ||
@@ -1255,34 +1339,36 @@ | ||
_context40.t0 = _regenerator["default"]; | ||
_context40.t1 = this.transportFactory(); | ||
_context40.t2 = url; | ||
_context40.t3 = _extends2["default"]; | ||
_context40.next = 10; | ||
_context42.t0 = _regenerator["default"]; | ||
_context42.t1 = this.transportFactory(); | ||
_context42.t2 = url; | ||
_context42.t3 = _extends2["default"]; | ||
_context42.next = 10; | ||
return _regenerator["default"].awrap(this.authorizationProvider('POST', url)); | ||
case 10: | ||
_context40.t4 = _context40.sent; | ||
_context40.t5 = { | ||
_context42.t4 = _context42.sent; | ||
_context42.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context40.t4 | ||
Authorization: _context42.t4 | ||
}; | ||
_context40.t6 = { | ||
_context42.t6 = cancelToken; | ||
_context42.t7 = { | ||
method: 'POST', | ||
headers: _context40.t5 | ||
headers: _context42.t5, | ||
cancelToken: _context42.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); | ||
_context42.t8 = this.agent; | ||
_context42.t9 = {}; | ||
_context42.t10 = data; | ||
_context42.t11 = (0, _context42.t3)(_context42.t7, _context42.t8, _context42.t9, _context42.t10); | ||
_context42.t12 = (0, _context42.t1)(_context42.t2, _context42.t11); | ||
_context42.next = 21; | ||
return _context42.t0.awrap.call(_context42.t0, _context42.t12); | ||
case 20: | ||
res = _context40.sent; | ||
return _context40.abrupt("return", res.data); | ||
case 21: | ||
res = _context42.sent; | ||
return _context42.abrupt("return", res.data); | ||
case 22: | ||
case 23: | ||
case "end": | ||
return _context40.stop(); | ||
return _context42.stop(); | ||
} | ||
@@ -1295,7 +1381,7 @@ } | ||
value: function multipartToJira(url, formData, queryParams) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, res; | ||
var sp, _i4, _Object$entries4, _Object$entries4$_i, k, v, res; | ||
return _regenerator["default"].async(function multipartToJira$(_context41) { | ||
return _regenerator["default"].async(function multipartToJira$(_context43) { | ||
while (1) { | ||
switch (_context41.prev = _context41.next) { | ||
switch (_context43.prev = _context43.next) { | ||
case 0: | ||
@@ -1307,4 +1393,4 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
for (_i3 = 0, _Object$entries3 = Object.entries(queryParams); _i3 < _Object$entries3.length; _i3++) { | ||
_Object$entries3$_i = (0, _slicedToArray2["default"])(_Object$entries3[_i3], 2), k = _Object$entries3$_i[0], v = _Object$entries3$_i[1]; | ||
for (_i4 = 0, _Object$entries4 = Object.entries(queryParams); _i4 < _Object$entries4.length; _i4++) { | ||
_Object$entries4$_i = (0, _slicedToArray2["default"])(_Object$entries4[_i4], 2), k = _Object$entries4$_i[0], v = _Object$entries4$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
@@ -1316,33 +1402,33 @@ } | ||
_context41.t0 = _regenerator["default"]; | ||
_context41.t1 = this.transportFactory(); | ||
_context41.t2 = url; | ||
_context41.t3 = formData; | ||
_context41.t4 = _extends2["default"]; | ||
_context41.next = 9; | ||
_context43.t0 = _regenerator["default"]; | ||
_context43.t1 = this.transportFactory(); | ||
_context43.t2 = url; | ||
_context43.t3 = formData; | ||
_context43.t4 = _extends2["default"]; | ||
_context43.next = 9; | ||
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 | ||
_context43.t5 = _context43.sent; | ||
_context43.t6 = formData.getHeaders()['content-type']; | ||
_context43.t7 = { | ||
Authorization: _context43.t5, | ||
'Content-Type': _context43.t6 | ||
}; | ||
_context41.t8 = { | ||
headers: _context41.t7 | ||
_context43.t8 = { | ||
headers: _context43.t7 | ||
}; | ||
_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; | ||
return _context41.t0.awrap.call(_context41.t0, _context41.t11); | ||
_context43.t9 = this.agent; | ||
_context43.t10 = (0, _context43.t4)(_context43.t8, _context43.t9); | ||
_context43.t11 = _context43.t1.post.call(_context43.t1, _context43.t2, _context43.t3, _context43.t10); | ||
_context43.next = 18; | ||
return _context43.t0.awrap.call(_context43.t0, _context43.t11); | ||
case 18: | ||
res = _context41.sent; | ||
return _context41.abrupt("return", res.data); | ||
res = _context43.sent; | ||
return _context43.abrupt("return", res.data); | ||
case 20: | ||
case "end": | ||
return _context41.stop(); | ||
return _context43.stop(); | ||
} | ||
@@ -1355,7 +1441,7 @@ } | ||
value: function putToJira(url, params, queryParams) { | ||
var sp, _i4, _Object$entries4, _Object$entries4$_i, k, v, res; | ||
var sp, _i5, _Object$entries5, _Object$entries5$_i, k, v, res; | ||
return _regenerator["default"].async(function putToJira$(_context42) { | ||
return _regenerator["default"].async(function putToJira$(_context44) { | ||
while (1) { | ||
switch (_context42.prev = _context42.next) { | ||
switch (_context44.prev = _context44.next) { | ||
case 0: | ||
@@ -1367,4 +1453,4 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
for (_i4 = 0, _Object$entries4 = Object.entries(queryParams); _i4 < _Object$entries4.length; _i4++) { | ||
_Object$entries4$_i = (0, _slicedToArray2["default"])(_Object$entries4[_i4], 2), k = _Object$entries4$_i[0], v = _Object$entries4$_i[1]; | ||
for (_i5 = 0, _Object$entries5 = Object.entries(queryParams); _i5 < _Object$entries5.length; _i5++) { | ||
_Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i5], 2), k = _Object$entries5$_i[0], v = _Object$entries5$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
@@ -1376,34 +1462,34 @@ } | ||
_context42.t0 = _regenerator["default"]; | ||
_context42.t1 = this.transportFactory(); | ||
_context42.t2 = url; | ||
_context42.t3 = _extends2["default"]; | ||
_context42.next = 8; | ||
_context44.t0 = _regenerator["default"]; | ||
_context44.t1 = this.transportFactory(); | ||
_context44.t2 = url; | ||
_context44.t3 = _extends2["default"]; | ||
_context44.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('PUT', url)); | ||
case 8: | ||
_context42.t4 = _context42.sent; | ||
_context42.t5 = { | ||
_context44.t4 = _context44.sent; | ||
_context44.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context42.t4 | ||
Authorization: _context44.t4 | ||
}; | ||
_context42.t6 = JSON.stringify(params); | ||
_context42.t7 = { | ||
_context44.t6 = JSON.stringify(params); | ||
_context44.t7 = { | ||
method: 'PUT', | ||
headers: _context42.t5, | ||
data: _context42.t6 | ||
headers: _context44.t5, | ||
data: _context44.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); | ||
_context44.t8 = this.agent; | ||
_context44.t9 = (0, _context44.t3)(_context44.t7, _context44.t8); | ||
_context44.t10 = (0, _context44.t1)(_context44.t2, _context44.t9); | ||
_context44.next = 17; | ||
return _context44.t0.awrap.call(_context44.t0, _context44.t10); | ||
case 17: | ||
res = _context42.sent; | ||
return _context42.abrupt("return", res.data); | ||
res = _context44.sent; | ||
return _context44.abrupt("return", res.data); | ||
case 19: | ||
case "end": | ||
return _context42.stop(); | ||
return _context44.stop(); | ||
} | ||
@@ -1416,7 +1502,7 @@ } | ||
value: function deleteToJira(url, queryParams) { | ||
var sp, _i5, _Object$entries5, _Object$entries5$_i, k, v, res; | ||
var sp, _i6, _Object$entries6, _Object$entries6$_i, k, v, res; | ||
return _regenerator["default"].async(function deleteToJira$(_context43) { | ||
return _regenerator["default"].async(function deleteToJira$(_context45) { | ||
while (1) { | ||
switch (_context43.prev = _context43.next) { | ||
switch (_context45.prev = _context45.next) { | ||
case 0: | ||
@@ -1428,4 +1514,4 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
for (_i5 = 0, _Object$entries5 = Object.entries(queryParams); _i5 < _Object$entries5.length; _i5++) { | ||
_Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i5], 2), k = _Object$entries5$_i[0], v = _Object$entries5$_i[1]; | ||
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)); | ||
@@ -1437,32 +1523,32 @@ } | ||
_context43.t0 = _regenerator["default"]; | ||
_context43.t1 = this.transportFactory(); | ||
_context43.t2 = url; | ||
_context43.t3 = _extends2["default"]; | ||
_context43.next = 8; | ||
_context45.t0 = _regenerator["default"]; | ||
_context45.t1 = this.transportFactory(); | ||
_context45.t2 = url; | ||
_context45.t3 = _extends2["default"]; | ||
_context45.next = 8; | ||
return _regenerator["default"].awrap(this.authorizationProvider('DELETE', url)); | ||
case 8: | ||
_context43.t4 = _context43.sent; | ||
_context43.t5 = { | ||
_context45.t4 = _context45.sent; | ||
_context45.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context43.t4 | ||
Authorization: _context45.t4 | ||
}; | ||
_context43.t6 = { | ||
_context45.t6 = { | ||
method: 'DELETE', | ||
headers: _context43.t5 | ||
headers: _context45.t5 | ||
}; | ||
_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); | ||
_context45.t7 = this.agent; | ||
_context45.t8 = (0, _context45.t3)(_context45.t6, _context45.t7); | ||
_context45.t9 = (0, _context45.t1)(_context45.t2, _context45.t8); | ||
_context45.next = 16; | ||
return _context45.t0.awrap.call(_context45.t0, _context45.t9); | ||
case 16: | ||
res = _context43.sent; | ||
return _context43.abrupt("return", res.data); | ||
res = _context45.sent; | ||
return _context45.abrupt("return", res.data); | ||
case 18: | ||
case "end": | ||
return _context43.stop(); | ||
return _context45.stop(); | ||
} | ||
@@ -1469,0 +1555,0 @@ } |
@@ -1,4 +0,5 @@ | ||
import { Filter, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { FilterSearchResults, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { JiraSiteInfo } from '@atlassianlabs/jira-pi-common-models/JiraSiteInfo'; | ||
import { AgentProvider } from '@atlassianlabs/pi-client-common/agent'; | ||
import { CancelToken } from 'axios'; | ||
import { AuthorizationProvider, JiraClient, TransportFactory } from './client'; | ||
@@ -9,3 +10,3 @@ export declare class JiraCloudClient<S extends JiraSiteInfo> extends JiraClient<S> { | ||
getProjects(query?: string, orderBy?: string): Promise<Project[]>; | ||
searchFilters(query: string): Promise<Filter[]>; | ||
searchFilters(query: string, maxResults?: number, startAt?: number, cancelToken?: CancelToken): Promise<FilterSearchResults>; | ||
} |
@@ -107,4 +107,4 @@ "use strict"; | ||
key: "searchFilters", | ||
value: function searchFilters(query) { | ||
var res; | ||
value: function searchFilters(query, maxResults, startAt, cancelToken) { | ||
var res, results, searchResult; | ||
return _regenerator["default"].async(function searchFilters$(_context3) { | ||
@@ -116,29 +116,37 @@ while (1) { | ||
return _regenerator["default"].awrap(this.getFromJira('filter/search', { | ||
expand: 'jql,favourite', | ||
expand: 'favourite,owner,jql,viewUrl', | ||
filterName: query, | ||
maxResults: 25, | ||
orderBy: '+NAME' | ||
})); | ||
orderBy: '+NAME', | ||
startAt: startAt, | ||
maxResults: maxResults | ||
}, cancelToken)); | ||
case 2: | ||
res = _context3.sent; | ||
results = []; | ||
searchResult = { | ||
maxResults: res.maxResults, | ||
offset: res.startAt, | ||
total: res.total, | ||
isLast: res.isLast, | ||
filters: [] | ||
}; | ||
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 | ||
}; | ||
})); | ||
searchResult.filters = results; | ||
return _context3.abrupt("return", searchResult); | ||
case 5: | ||
return _context3.abrupt("return", []); | ||
case 6: | ||
case 8: | ||
case "end": | ||
@@ -145,0 +153,0 @@ return _context3.stop(); |
@@ -613,2 +613,28 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
}, null, this); | ||
} | ||
}, { | ||
key: "validateJql", | ||
value: function validateJql(jql, cancelToken) { | ||
var res; | ||
return _regeneratorRuntime.async(function validateJql$(_context19) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
_context19.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira('jql/parse', { | ||
queries: [jql] | ||
}, cancelToken)); | ||
case 2: | ||
res = _context19.sent; | ||
return _context19.abrupt("return", { | ||
errors: res.data && Array.isArray(res.data.errors) ? res.data.errors : [] | ||
}); | ||
case 4: | ||
case "end": | ||
return _context19.stop(); | ||
} | ||
} | ||
}, null, this); | ||
} // Filters | ||
@@ -620,25 +646,25 @@ | ||
var res; | ||
return _regeneratorRuntime.async(function getFavoriteFilters$(_context19) { | ||
return _regeneratorRuntime.async(function getFavoriteFilters$(_context20) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
_context19.next = 2; | ||
_context20.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira('filter/favourite')); | ||
case 2: | ||
res = _context19.sent; | ||
res = _context20.sent; | ||
if (!Array.isArray(res)) { | ||
_context19.next = 5; | ||
_context20.next = 5; | ||
break; | ||
} | ||
return _context19.abrupt("return", res); | ||
return _context20.abrupt("return", res); | ||
case 5: | ||
return _context19.abrupt("return", []); | ||
return _context20.abrupt("return", []); | ||
case 6: | ||
case "end": | ||
return _context19.stop(); | ||
return _context20.stop(); | ||
} | ||
@@ -652,25 +678,25 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getMyFilters$(_context20) { | ||
return _regeneratorRuntime.async(function getMyFilters$(_context21) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
_context20.next = 2; | ||
_context21.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira('filter/my')); | ||
case 2: | ||
res = _context20.sent; | ||
res = _context21.sent; | ||
if (!Array.isArray(res)) { | ||
_context20.next = 5; | ||
_context21.next = 5; | ||
break; | ||
} | ||
return _context20.abrupt("return", res); | ||
return _context21.abrupt("return", res); | ||
case 5: | ||
return _context20.abrupt("return", []); | ||
return _context21.abrupt("return", []); | ||
case 6: | ||
case "end": | ||
return _context20.stop(); | ||
return _context21.stop(); | ||
} | ||
@@ -684,7 +710,7 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getFilter$(_context21) { | ||
return _regeneratorRuntime.async(function getFilter$(_context22) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
_context21.next = 2; | ||
_context22.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira("filter/".concat(filterId), { | ||
@@ -695,17 +721,17 @@ expand: 'jql,favourite' | ||
case 2: | ||
res = _context21.sent; | ||
res = _context22.sent; | ||
if (!res) { | ||
_context21.next = 5; | ||
_context22.next = 5; | ||
break; | ||
} | ||
return _context21.abrupt("return", res); | ||
return _context22.abrupt("return", res); | ||
case 5: | ||
return _context21.abrupt("return", undefined); | ||
return _context22.abrupt("return", undefined); | ||
case 6: | ||
case "end": | ||
return _context21.stop(); | ||
return _context22.stop(); | ||
} | ||
@@ -722,16 +748,16 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function searchForIssuesUsingJqlGet$(_context22) { | ||
return _regeneratorRuntime.async(function searchForIssuesUsingJqlGet$(_context23) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
_context22.next = 2; | ||
_context23.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira('search', getSearchProps(jql, fields, maxResults, startAt))); | ||
case 2: | ||
res = _context22.sent; | ||
return _context22.abrupt("return", res); | ||
res = _context23.sent; | ||
return _context23.abrupt("return", res); | ||
case 4: | ||
case "end": | ||
return _context22.stop(); | ||
return _context23.stop(); | ||
} | ||
@@ -747,16 +773,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function createVersion$(_context23) { | ||
return _regeneratorRuntime.async(function createVersion$(_context24) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
_context23.next = 2; | ||
_context24.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira('version', params)); | ||
case 2: | ||
result = _context23.sent; | ||
return _context23.abrupt("return", readVersion(result)); | ||
result = _context24.sent; | ||
return _context24.abrupt("return", readVersion(result)); | ||
case 4: | ||
case "end": | ||
return _context23.stop(); | ||
return _context24.stop(); | ||
} | ||
@@ -771,16 +797,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function createComponent$(_context24) { | ||
return _regeneratorRuntime.async(function createComponent$(_context25) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context24.next = 2; | ||
_context25.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira('component', params)); | ||
case 2: | ||
result = _context24.sent; | ||
return _context24.abrupt("return", readComponent(result)); | ||
result = _context25.sent; | ||
return _context25.abrupt("return", readComponent(result)); | ||
case 4: | ||
case "end": | ||
return _context24.stop(); | ||
return _context25.stop(); | ||
} | ||
@@ -795,11 +821,11 @@ } | ||
var resp; | ||
return _regeneratorRuntime.async(function createIssueLink$(_context25) { | ||
return _regeneratorRuntime.async(function createIssueLink$(_context26) { | ||
while (1) { | ||
switch (_context25.prev = _context25.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context25.next = 2; | ||
_context26.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira('issueLink', linkData)); | ||
case 2: | ||
_context25.next = 4; | ||
_context26.next = 4; | ||
return _regeneratorRuntime.awrap(this.getFromJira("issue/".concat(parentIssueKey), { | ||
@@ -810,8 +836,8 @@ fields: 'issuelinks' | ||
case 4: | ||
resp = _context25.sent; | ||
return _context25.abrupt("return", readMinimalIssueLinks(resp.fields['issuelinks'], this.site)); | ||
resp = _context26.sent; | ||
return _context26.abrupt("return", readMinimalIssueLinks(resp.fields['issuelinks'], this.site)); | ||
case 6: | ||
case "end": | ||
return _context25.stop(); | ||
return _context26.stop(); | ||
} | ||
@@ -826,16 +852,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function addWorklog$(_context26) { | ||
return _regeneratorRuntime.async(function addWorklog$(_context27) { | ||
while (1) { | ||
switch (_context26.prev = _context26.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context26.next = 2; | ||
_context27.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira("issue/".concat(issuekey, "/worklog"), params, queryParams)); | ||
case 2: | ||
result = _context26.sent; | ||
return _context26.abrupt("return", result); | ||
result = _context27.sent; | ||
return _context27.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context26.stop(); | ||
return _context27.stop(); | ||
} | ||
@@ -850,16 +876,16 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getWatchers$(_context27) { | ||
return _regeneratorRuntime.async(function getWatchers$(_context28) { | ||
while (1) { | ||
switch (_context27.prev = _context27.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context27.next = 2; | ||
_context28.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira("issue/".concat(issueIdOrKey, "/watchers"))); | ||
case 2: | ||
res = _context27.sent; | ||
return _context27.abrupt("return", readWatches(res)); | ||
res = _context28.sent; | ||
return _context28.abrupt("return", readWatches(res)); | ||
case 4: | ||
case "end": | ||
return _context27.stop(); | ||
return _context28.stop(); | ||
} | ||
@@ -873,16 +899,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function addWatcher$(_context28) { | ||
return _regeneratorRuntime.async(function addWatcher$(_context29) { | ||
while (1) { | ||
switch (_context28.prev = _context28.next) { | ||
switch (_context29.prev = _context29.next) { | ||
case 0: | ||
_context28.next = 2; | ||
_context29.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira("issue/".concat(issuekey, "/watchers"), accountId)); | ||
case 2: | ||
result = _context28.sent; | ||
return _context28.abrupt("return", result); | ||
result = _context29.sent; | ||
return _context29.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context28.stop(); | ||
return _context29.stop(); | ||
} | ||
@@ -896,7 +922,7 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function removeWatcher$(_context29) { | ||
return _regeneratorRuntime.async(function removeWatcher$(_context30) { | ||
while (1) { | ||
switch (_context29.prev = _context29.next) { | ||
switch (_context30.prev = _context30.next) { | ||
case 0: | ||
_context29.next = 2; | ||
_context30.next = 2; | ||
return _regeneratorRuntime.awrap(this.deleteToJira("issue/".concat(issuekey, "/watchers"), { | ||
@@ -907,8 +933,8 @@ accountId: accountId | ||
case 2: | ||
result = _context29.sent; | ||
return _context29.abrupt("return", result); | ||
result = _context30.sent; | ||
return _context30.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context29.stop(); | ||
return _context30.stop(); | ||
} | ||
@@ -923,16 +949,16 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getVotes$(_context30) { | ||
return _regeneratorRuntime.async(function getVotes$(_context31) { | ||
while (1) { | ||
switch (_context30.prev = _context30.next) { | ||
switch (_context31.prev = _context31.next) { | ||
case 0: | ||
_context30.next = 2; | ||
_context31.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira("issue/".concat(issueIdOrKey, "/votes"))); | ||
case 2: | ||
res = _context30.sent; | ||
return _context30.abrupt("return", readVotes(res)); | ||
res = _context31.sent; | ||
return _context31.abrupt("return", readVotes(res)); | ||
case 4: | ||
case "end": | ||
return _context30.stop(); | ||
return _context31.stop(); | ||
} | ||
@@ -946,16 +972,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function addVote$(_context31) { | ||
return _regeneratorRuntime.async(function addVote$(_context32) { | ||
while (1) { | ||
switch (_context31.prev = _context31.next) { | ||
switch (_context32.prev = _context32.next) { | ||
case 0: | ||
_context31.next = 2; | ||
_context32.next = 2; | ||
return _regeneratorRuntime.awrap(this.postToJira("issue/".concat(issuekey, "/votes"))); | ||
case 2: | ||
result = _context31.sent; | ||
return _context31.abrupt("return", result); | ||
result = _context32.sent; | ||
return _context32.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context31.stop(); | ||
return _context32.stop(); | ||
} | ||
@@ -969,16 +995,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function removeVote$(_context32) { | ||
return _regeneratorRuntime.async(function removeVote$(_context33) { | ||
while (1) { | ||
switch (_context32.prev = _context32.next) { | ||
switch (_context33.prev = _context33.next) { | ||
case 0: | ||
_context32.next = 2; | ||
_context33.next = 2; | ||
return _regeneratorRuntime.awrap(this.deleteToJira("issue/".concat(issuekey, "/votes"))); | ||
case 2: | ||
result = _context32.sent; | ||
return _context32.abrupt("return", result); | ||
result = _context33.sent; | ||
return _context33.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context32.stop(); | ||
return _context33.stop(); | ||
} | ||
@@ -992,16 +1018,16 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getIssueLinkTypes$(_context33) { | ||
return _regeneratorRuntime.async(function getIssueLinkTypes$(_context34) { | ||
while (1) { | ||
switch (_context33.prev = _context33.next) { | ||
switch (_context34.prev = _context34.next) { | ||
case 0: | ||
_context33.next = 2; | ||
_context34.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira('issueLinkType')); | ||
case 2: | ||
res = _context33.sent; | ||
return _context33.abrupt("return", res.issueLinkTypes ? res.issueLinkTypes : []); | ||
res = _context34.sent; | ||
return _context34.abrupt("return", res.issueLinkTypes ? res.issueLinkTypes : []); | ||
case 4: | ||
case "end": | ||
return _context33.stop(); | ||
return _context34.stop(); | ||
} | ||
@@ -1016,18 +1042,18 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getFields$(_context34) { | ||
return _regeneratorRuntime.async(function getFields$(_context35) { | ||
while (1) { | ||
switch (_context34.prev = _context34.next) { | ||
switch (_context35.prev = _context35.next) { | ||
case 0: | ||
_context34.next = 2; | ||
_context35.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira('field')); | ||
case 2: | ||
res = _context34.sent; | ||
res = _context35.sent; | ||
if (!Array.isArray(res)) { | ||
_context34.next = 5; | ||
_context35.next = 5; | ||
break; | ||
} | ||
return _context34.abrupt("return", res.map(function (f) { | ||
return _context35.abrupt("return", res.map(function (f) { | ||
return readField(f); | ||
@@ -1037,7 +1063,7 @@ })); | ||
case 5: | ||
return _context34.abrupt("return", []); | ||
return _context35.abrupt("return", []); | ||
case 6: | ||
case "end": | ||
return _context34.stop(); | ||
return _context35.stop(); | ||
} | ||
@@ -1052,16 +1078,16 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function getCurrentUser$(_context35) { | ||
return _regeneratorRuntime.async(function getCurrentUser$(_context36) { | ||
while (1) { | ||
switch (_context35.prev = _context35.next) { | ||
switch (_context36.prev = _context36.next) { | ||
case 0: | ||
_context35.next = 2; | ||
_context36.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJira('myself')); | ||
case 2: | ||
res = _context35.sent; | ||
return _context35.abrupt("return", res); | ||
res = _context36.sent; | ||
return _context36.abrupt("return", res); | ||
case 4: | ||
case "end": | ||
return _context35.stop(); | ||
return _context36.stop(); | ||
} | ||
@@ -1076,16 +1102,16 @@ } | ||
var res; | ||
return _regeneratorRuntime.async(function addAttachments$(_context36) { | ||
return _regeneratorRuntime.async(function addAttachments$(_context37) { | ||
while (1) { | ||
switch (_context36.prev = _context36.next) { | ||
switch (_context37.prev = _context37.next) { | ||
case 0: | ||
_context36.next = 2; | ||
_context37.next = 2; | ||
return _regeneratorRuntime.awrap(this.multipartToJira("issue/".concat(issuekey, "/attachments"), formData)); | ||
case 2: | ||
res = _context36.sent; | ||
return _context36.abrupt("return", res); | ||
res = _context37.sent; | ||
return _context37.abrupt("return", res); | ||
case 4: | ||
case "end": | ||
return _context36.stop(); | ||
return _context37.stop(); | ||
} | ||
@@ -1099,16 +1125,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function deleteAttachment$(_context37) { | ||
return _regeneratorRuntime.async(function deleteAttachment$(_context38) { | ||
while (1) { | ||
switch (_context37.prev = _context37.next) { | ||
switch (_context38.prev = _context38.next) { | ||
case 0: | ||
_context37.next = 2; | ||
_context38.next = 2; | ||
return _regeneratorRuntime.awrap(this.deleteToJira("attachment/".concat(attachmentId))); | ||
case 2: | ||
result = _context37.sent; | ||
return _context37.abrupt("return", result); | ||
result = _context38.sent; | ||
return _context38.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context37.stop(); | ||
return _context38.stop(); | ||
} | ||
@@ -1122,16 +1148,16 @@ } | ||
var result; | ||
return _regeneratorRuntime.async(function deleteIssuelink$(_context38) { | ||
return _regeneratorRuntime.async(function deleteIssuelink$(_context39) { | ||
while (1) { | ||
switch (_context38.prev = _context38.next) { | ||
switch (_context39.prev = _context39.next) { | ||
case 0: | ||
_context38.next = 2; | ||
_context39.next = 2; | ||
return _regeneratorRuntime.awrap(this.deleteToJira("issuelink/".concat(linkId))); | ||
case 2: | ||
result = _context38.sent; | ||
return _context38.abrupt("return", result); | ||
result = _context39.sent; | ||
return _context39.abrupt("return", result); | ||
case 4: | ||
case "end": | ||
return _context38.stop(); | ||
return _context39.stop(); | ||
} | ||
@@ -1146,5 +1172,5 @@ } | ||
return _regeneratorRuntime.async(function getFromJira$(_context39) { | ||
return _regeneratorRuntime.async(function getFromJira$(_context40) { | ||
while (1) { | ||
switch (_context39.prev = _context39.next) { | ||
switch (_context40.prev = _context40.next) { | ||
case 0: | ||
@@ -1164,34 +1190,34 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
_context39.t0 = _regeneratorRuntime; | ||
_context39.t1 = this.transportFactory(); | ||
_context39.t2 = url; | ||
_context39.t3 = _extends; | ||
_context39.next = 8; | ||
_context40.t0 = _regeneratorRuntime; | ||
_context40.t1 = this.transportFactory(); | ||
_context40.t2 = url; | ||
_context40.t3 = _extends; | ||
_context40.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('GET', url)); | ||
case 8: | ||
_context39.t4 = _context39.sent; | ||
_context39.t5 = { | ||
_context40.t4 = _context40.sent; | ||
_context40.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context39.t4 | ||
Authorization: _context40.t4 | ||
}; | ||
_context39.t6 = cancelToken; | ||
_context39.t7 = { | ||
_context40.t6 = cancelToken; | ||
_context40.t7 = { | ||
method: 'GET', | ||
headers: _context39.t5, | ||
cancelToken: _context39.t6 | ||
headers: _context40.t5, | ||
cancelToken: _context40.t6 | ||
}; | ||
_context39.t8 = this.agent; | ||
_context39.t9 = (0, _context39.t3)(_context39.t7, _context39.t8); | ||
_context39.t10 = (0, _context39.t1)(_context39.t2, _context39.t9); | ||
_context39.next = 17; | ||
return _context39.t0.awrap.call(_context39.t0, _context39.t10); | ||
_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 17: | ||
res = _context39.sent; | ||
return _context39.abrupt("return", res.data); | ||
res = _context40.sent; | ||
return _context40.abrupt("return", res.data); | ||
case 19: | ||
case "end": | ||
return _context39.stop(); | ||
return _context40.stop(); | ||
} | ||
@@ -1202,11 +1228,11 @@ } | ||
}, { | ||
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$(_context41) { | ||
while (1) { | ||
switch (_context40.prev = _context40.next) { | ||
switch (_context41.prev = _context41.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
url = "".concat(this.baseUrl, "/").concat(url); | ||
@@ -1222,2 +1248,60 @@ if (queryParams) { | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} | ||
_context41.t0 = _regeneratorRuntime; | ||
_context41.t1 = this.transportFactory(); | ||
_context41.t2 = url; | ||
_context41.t3 = _extends; | ||
_context41.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('GET', url)); | ||
case 8: | ||
_context41.t4 = _context41.sent; | ||
_context41.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context41.t4 | ||
}; | ||
_context41.t6 = cancelToken; | ||
_context41.t7 = { | ||
method: 'GET', | ||
headers: _context41.t5, | ||
cancelToken: _context41.t6 | ||
}; | ||
_context41.t8 = this.agent; | ||
_context41.t9 = (0, _context41.t3)(_context41.t7, _context41.t8); | ||
_context41.t10 = (0, _context41.t1)(_context41.t2, _context41.t9); | ||
_context41.next = 17; | ||
return _context41.t0.awrap.call(_context41.t0, _context41.t10); | ||
case 17: | ||
res = _context41.sent; | ||
return _context41.abrupt("return", res.data); | ||
case 19: | ||
case "end": | ||
return _context41.stop(); | ||
} | ||
} | ||
}, null, this); | ||
} | ||
}, { | ||
key: "postToJira", | ||
value: function postToJira(url, params, queryParams, cancelToken) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, data, res; | ||
return _regeneratorRuntime.async(function postToJira$(_context42) { | ||
while (1) { | ||
switch (_context42.prev = _context42.next) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
if (queryParams) { | ||
sp = new URLSearchParams(); | ||
for (_i3 = 0, _Object$entries3 = Object.entries(queryParams); _i3 < _Object$entries3.length; _i3++) { | ||
_Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2), k = _Object$entries3$_i[0], v = _Object$entries3$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
} | ||
url = "".concat(url, "?").concat(sp.toString()); | ||
} // yup, jira's silly and accepts post with no data | ||
@@ -1234,34 +1318,36 @@ | ||
_context40.t0 = _regeneratorRuntime; | ||
_context40.t1 = this.transportFactory(); | ||
_context40.t2 = url; | ||
_context40.t3 = _extends; | ||
_context40.next = 10; | ||
_context42.t0 = _regeneratorRuntime; | ||
_context42.t1 = this.transportFactory(); | ||
_context42.t2 = url; | ||
_context42.t3 = _extends; | ||
_context42.next = 10; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('POST', url)); | ||
case 10: | ||
_context40.t4 = _context40.sent; | ||
_context40.t5 = { | ||
_context42.t4 = _context42.sent; | ||
_context42.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context40.t4 | ||
Authorization: _context42.t4 | ||
}; | ||
_context40.t6 = { | ||
_context42.t6 = cancelToken; | ||
_context42.t7 = { | ||
method: 'POST', | ||
headers: _context40.t5 | ||
headers: _context42.t5, | ||
cancelToken: _context42.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); | ||
_context42.t8 = this.agent; | ||
_context42.t9 = {}; | ||
_context42.t10 = data; | ||
_context42.t11 = (0, _context42.t3)(_context42.t7, _context42.t8, _context42.t9, _context42.t10); | ||
_context42.t12 = (0, _context42.t1)(_context42.t2, _context42.t11); | ||
_context42.next = 21; | ||
return _context42.t0.awrap.call(_context42.t0, _context42.t12); | ||
case 20: | ||
res = _context40.sent; | ||
return _context40.abrupt("return", res.data); | ||
case 21: | ||
res = _context42.sent; | ||
return _context42.abrupt("return", res.data); | ||
case 22: | ||
case 23: | ||
case "end": | ||
return _context40.stop(); | ||
return _context42.stop(); | ||
} | ||
@@ -1274,7 +1360,7 @@ } | ||
value: function multipartToJira(url, formData, queryParams) { | ||
var sp, _i3, _Object$entries3, _Object$entries3$_i, k, v, res; | ||
var sp, _i4, _Object$entries4, _Object$entries4$_i, k, v, res; | ||
return _regeneratorRuntime.async(function multipartToJira$(_context41) { | ||
return _regeneratorRuntime.async(function multipartToJira$(_context43) { | ||
while (1) { | ||
switch (_context41.prev = _context41.next) { | ||
switch (_context43.prev = _context43.next) { | ||
case 0: | ||
@@ -1286,4 +1372,4 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
for (_i3 = 0, _Object$entries3 = Object.entries(queryParams); _i3 < _Object$entries3.length; _i3++) { | ||
_Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2), k = _Object$entries3$_i[0], v = _Object$entries3$_i[1]; | ||
for (_i4 = 0, _Object$entries4 = Object.entries(queryParams); _i4 < _Object$entries4.length; _i4++) { | ||
_Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2), k = _Object$entries4$_i[0], v = _Object$entries4$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
@@ -1295,33 +1381,33 @@ } | ||
_context41.t0 = _regeneratorRuntime; | ||
_context41.t1 = this.transportFactory(); | ||
_context41.t2 = url; | ||
_context41.t3 = formData; | ||
_context41.t4 = _extends; | ||
_context41.next = 9; | ||
_context43.t0 = _regeneratorRuntime; | ||
_context43.t1 = this.transportFactory(); | ||
_context43.t2 = url; | ||
_context43.t3 = formData; | ||
_context43.t4 = _extends; | ||
_context43.next = 9; | ||
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 | ||
_context43.t5 = _context43.sent; | ||
_context43.t6 = formData.getHeaders()['content-type']; | ||
_context43.t7 = { | ||
Authorization: _context43.t5, | ||
'Content-Type': _context43.t6 | ||
}; | ||
_context41.t8 = { | ||
headers: _context41.t7 | ||
_context43.t8 = { | ||
headers: _context43.t7 | ||
}; | ||
_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; | ||
return _context41.t0.awrap.call(_context41.t0, _context41.t11); | ||
_context43.t9 = this.agent; | ||
_context43.t10 = (0, _context43.t4)(_context43.t8, _context43.t9); | ||
_context43.t11 = _context43.t1.post.call(_context43.t1, _context43.t2, _context43.t3, _context43.t10); | ||
_context43.next = 18; | ||
return _context43.t0.awrap.call(_context43.t0, _context43.t11); | ||
case 18: | ||
res = _context41.sent; | ||
return _context41.abrupt("return", res.data); | ||
res = _context43.sent; | ||
return _context43.abrupt("return", res.data); | ||
case 20: | ||
case "end": | ||
return _context41.stop(); | ||
return _context43.stop(); | ||
} | ||
@@ -1334,7 +1420,7 @@ } | ||
value: function putToJira(url, params, queryParams) { | ||
var sp, _i4, _Object$entries4, _Object$entries4$_i, k, v, res; | ||
var sp, _i5, _Object$entries5, _Object$entries5$_i, k, v, res; | ||
return _regeneratorRuntime.async(function putToJira$(_context42) { | ||
return _regeneratorRuntime.async(function putToJira$(_context44) { | ||
while (1) { | ||
switch (_context42.prev = _context42.next) { | ||
switch (_context44.prev = _context44.next) { | ||
case 0: | ||
@@ -1346,4 +1432,4 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
for (_i4 = 0, _Object$entries4 = Object.entries(queryParams); _i4 < _Object$entries4.length; _i4++) { | ||
_Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2), k = _Object$entries4$_i[0], v = _Object$entries4$_i[1]; | ||
for (_i5 = 0, _Object$entries5 = Object.entries(queryParams); _i5 < _Object$entries5.length; _i5++) { | ||
_Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2), k = _Object$entries5$_i[0], v = _Object$entries5$_i[1]; | ||
sp.append(k, "".concat(v)); | ||
@@ -1355,34 +1441,34 @@ } | ||
_context42.t0 = _regeneratorRuntime; | ||
_context42.t1 = this.transportFactory(); | ||
_context42.t2 = url; | ||
_context42.t3 = _extends; | ||
_context42.next = 8; | ||
_context44.t0 = _regeneratorRuntime; | ||
_context44.t1 = this.transportFactory(); | ||
_context44.t2 = url; | ||
_context44.t3 = _extends; | ||
_context44.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('PUT', url)); | ||
case 8: | ||
_context42.t4 = _context42.sent; | ||
_context42.t5 = { | ||
_context44.t4 = _context44.sent; | ||
_context44.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context42.t4 | ||
Authorization: _context44.t4 | ||
}; | ||
_context42.t6 = JSON.stringify(params); | ||
_context42.t7 = { | ||
_context44.t6 = JSON.stringify(params); | ||
_context44.t7 = { | ||
method: 'PUT', | ||
headers: _context42.t5, | ||
data: _context42.t6 | ||
headers: _context44.t5, | ||
data: _context44.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); | ||
_context44.t8 = this.agent; | ||
_context44.t9 = (0, _context44.t3)(_context44.t7, _context44.t8); | ||
_context44.t10 = (0, _context44.t1)(_context44.t2, _context44.t9); | ||
_context44.next = 17; | ||
return _context44.t0.awrap.call(_context44.t0, _context44.t10); | ||
case 17: | ||
res = _context42.sent; | ||
return _context42.abrupt("return", res.data); | ||
res = _context44.sent; | ||
return _context44.abrupt("return", res.data); | ||
case 19: | ||
case "end": | ||
return _context42.stop(); | ||
return _context44.stop(); | ||
} | ||
@@ -1395,7 +1481,7 @@ } | ||
value: function deleteToJira(url, queryParams) { | ||
var sp, _i5, _Object$entries5, _Object$entries5$_i, k, v, res; | ||
var sp, _i6, _Object$entries6, _Object$entries6$_i, k, v, res; | ||
return _regeneratorRuntime.async(function deleteToJira$(_context43) { | ||
return _regeneratorRuntime.async(function deleteToJira$(_context45) { | ||
while (1) { | ||
switch (_context43.prev = _context43.next) { | ||
switch (_context45.prev = _context45.next) { | ||
case 0: | ||
@@ -1407,4 +1493,4 @@ url = "".concat(this.baseUrl, "/api/").concat(this.apiVersion, "/").concat(url); | ||
for (_i5 = 0, _Object$entries5 = Object.entries(queryParams); _i5 < _Object$entries5.length; _i5++) { | ||
_Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2), k = _Object$entries5$_i[0], v = _Object$entries5$_i[1]; | ||
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)); | ||
@@ -1416,32 +1502,32 @@ } | ||
_context43.t0 = _regeneratorRuntime; | ||
_context43.t1 = this.transportFactory(); | ||
_context43.t2 = url; | ||
_context43.t3 = _extends; | ||
_context43.next = 8; | ||
_context45.t0 = _regeneratorRuntime; | ||
_context45.t1 = this.transportFactory(); | ||
_context45.t2 = url; | ||
_context45.t3 = _extends; | ||
_context45.next = 8; | ||
return _regeneratorRuntime.awrap(this.authorizationProvider('DELETE', url)); | ||
case 8: | ||
_context43.t4 = _context43.sent; | ||
_context43.t5 = { | ||
_context45.t4 = _context45.sent; | ||
_context45.t5 = { | ||
'Content-Type': 'application/json', | ||
Authorization: _context43.t4 | ||
Authorization: _context45.t4 | ||
}; | ||
_context43.t6 = { | ||
_context45.t6 = { | ||
method: 'DELETE', | ||
headers: _context43.t5 | ||
headers: _context45.t5 | ||
}; | ||
_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); | ||
_context45.t7 = this.agent; | ||
_context45.t8 = (0, _context45.t3)(_context45.t6, _context45.t7); | ||
_context45.t9 = (0, _context45.t1)(_context45.t2, _context45.t8); | ||
_context45.next = 16; | ||
return _context45.t0.awrap.call(_context45.t0, _context45.t9); | ||
case 16: | ||
res = _context43.sent; | ||
return _context43.abrupt("return", res.data); | ||
res = _context45.sent; | ||
return _context45.abrupt("return", res.data); | ||
case 18: | ||
case "end": | ||
return _context43.stop(); | ||
return _context45.stop(); | ||
} | ||
@@ -1448,0 +1534,0 @@ } |
@@ -91,4 +91,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
key: "searchFilters", | ||
value: function searchFilters(query) { | ||
var res; | ||
value: function searchFilters(query, maxResults, startAt, cancelToken) { | ||
var res, results, searchResult; | ||
return _regeneratorRuntime.async(function searchFilters$(_context3) { | ||
@@ -100,29 +100,37 @@ while (1) { | ||
return _regeneratorRuntime.awrap(this.getFromJira('filter/search', { | ||
expand: 'jql,favourite', | ||
expand: 'favourite,owner,jql,viewUrl', | ||
filterName: query, | ||
maxResults: 25, | ||
orderBy: '+NAME' | ||
})); | ||
orderBy: '+NAME', | ||
startAt: startAt, | ||
maxResults: maxResults | ||
}, cancelToken)); | ||
case 2: | ||
res = _context3.sent; | ||
results = []; | ||
searchResult = { | ||
maxResults: res.maxResults, | ||
offset: res.startAt, | ||
total: res.total, | ||
isLast: res.isLast, | ||
filters: [] | ||
}; | ||
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 | ||
}; | ||
})); | ||
searchResult.filters = results; | ||
return _context3.abrupt("return", searchResult); | ||
case 5: | ||
return _context3.abrupt("return", []); | ||
case 6: | ||
case 8: | ||
case "end": | ||
@@ -129,0 +137,0 @@ return _context3.stop(); |
@@ -92,3 +92,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
key: "searchFilters", | ||
value: function searchFilters(query) { | ||
value: function searchFilters(query, maxResults, startAt, cancelToken) { | ||
var res, favIds, resFilters, favRes, results, searchResult; | ||
return _regeneratorRuntime.async(function searchFilters$(_context3) { | ||
@@ -98,5 +99,45 @@ while (1) { | ||
case 0: | ||
return _context3.abrupt("return", []); | ||
_context3.next = 2; | ||
return _regeneratorRuntime.awrap(this.getFromJiraCustomUrl('greenhopper/1.0/savedfilter/list', { | ||
query: query | ||
}, cancelToken)); | ||
case 1: | ||
case 2: | ||
res = _context3.sent; | ||
favIds = []; | ||
resFilters = Array.isArray(res.filters) ? res.filters : []; | ||
_context3.next = 7; | ||
return _regeneratorRuntime.awrap(this.getFromJira('filter/favourite')); | ||
case 7: | ||
favRes = _context3.sent; | ||
if (Array.isArray(favRes)) { | ||
favIds = favRes.map(function (fav) { | ||
return fav.id; | ||
}); | ||
} | ||
results = []; | ||
searchResult = { | ||
maxResults: resFilters.length, | ||
offset: 0, | ||
total: resFilters.length, | ||
isLast: true, | ||
filters: [] | ||
}; | ||
results = resFilters.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) | ||
}; | ||
}); | ||
searchResult.filters = results; | ||
return _context3.abrupt("return", searchResult); | ||
case 14: | ||
case "end": | ||
@@ -106,3 +147,3 @@ return _context3.stop(); | ||
} | ||
}); | ||
}, null, this); | ||
} | ||
@@ -109,0 +150,0 @@ }]); |
{ | ||
"name": "@atlassianlabs/jira-pi-client", | ||
"version": "0.1.14", | ||
"version": "0.1.15-links", | ||
"description": "Transform jira meta information to a ui descriptor", | ||
@@ -15,5 +15,5 @@ "repository": { | ||
"dependencies": { | ||
"@atlassianlabs/jira-pi-common-models": "^0.1.14", | ||
"@atlassianlabs/jira-pi-meta-models": "^0.1.14", | ||
"@atlassianlabs/pi-client-common": "^0.1.14" | ||
"@atlassianlabs/jira-pi-common-models": "^0.1.15-links", | ||
"@atlassianlabs/jira-pi-meta-models": "^0.1.15-links", | ||
"@atlassianlabs/pi-client-common": "^0.1.15-links" | ||
}, | ||
@@ -24,5 +24,5 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "57a0be91795888a72d1139123153d3091721965a", | ||
"gitHead": "e59cb63ec99a531b2c69a1035f76351a2a19dabc", | ||
"main": "./index.js", | ||
"typings": "./index.d.ts" | ||
} |
@@ -1,4 +0,5 @@ | ||
import { Filter, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { FilterSearchResults, Project } from '@atlassianlabs/jira-pi-common-models/entities'; | ||
import { JiraSiteInfo } from '@atlassianlabs/jira-pi-common-models/JiraSiteInfo'; | ||
import { AgentProvider } from '@atlassianlabs/pi-client-common/agent'; | ||
import { CancelToken } from 'axios'; | ||
import { AuthorizationProvider, JiraClient, TransportFactory } from './client'; | ||
@@ -9,4 +10,4 @@ export declare class JiraServerClient<S extends JiraSiteInfo> extends JiraClient<S> { | ||
getProjects(query?: string, orderBy?: string): Promise<Project[]>; | ||
searchFilters(query: string): Promise<Filter[]>; | ||
searchFilters(query: string, maxResults?: number, startAt?: number, cancelToken?: CancelToken): Promise<FilterSearchResults>; | ||
} | ||
export declare function defaultJiraServerClient<S extends JiraSiteInfo>(site: S, username: string, password: string): JiraServerClient<S>; |
@@ -110,3 +110,4 @@ "use strict"; | ||
key: "searchFilters", | ||
value: function searchFilters(query) { | ||
value: function searchFilters(query, maxResults, startAt, cancelToken) { | ||
var res, favIds, resFilters, favRes, results, searchResult; | ||
return _regenerator["default"].async(function searchFilters$(_context3) { | ||
@@ -116,5 +117,45 @@ while (1) { | ||
case 0: | ||
return _context3.abrupt("return", []); | ||
_context3.next = 2; | ||
return _regenerator["default"].awrap(this.getFromJiraCustomUrl('greenhopper/1.0/savedfilter/list', { | ||
query: query | ||
}, cancelToken)); | ||
case 1: | ||
case 2: | ||
res = _context3.sent; | ||
favIds = []; | ||
resFilters = Array.isArray(res.filters) ? res.filters : []; | ||
_context3.next = 7; | ||
return _regenerator["default"].awrap(this.getFromJira('filter/favourite')); | ||
case 7: | ||
favRes = _context3.sent; | ||
if (Array.isArray(favRes)) { | ||
favIds = favRes.map(function (fav) { | ||
return fav.id; | ||
}); | ||
} | ||
results = []; | ||
searchResult = { | ||
maxResults: resFilters.length, | ||
offset: 0, | ||
total: resFilters.length, | ||
isLast: true, | ||
filters: [] | ||
}; | ||
results = resFilters.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) | ||
}; | ||
}); | ||
searchResult.filters = results; | ||
return _context3.abrupt("return", searchResult); | ||
case 14: | ||
case "end": | ||
@@ -124,3 +165,3 @@ return _context3.stop(); | ||
} | ||
}); | ||
}, null, this); | ||
} | ||
@@ -127,0 +168,0 @@ }]); |
131130
3358