UNPKG

91.4 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports["default"] = void 0;
9
10var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
12var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
14var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
16var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
18var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
20var _requestPromise = _interopRequireDefault(require("request-promise"));
21
22var _url = _interopRequireDefault(require("url"));
23
24function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
26function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
28/**
29 * @name JiraApi
30 * @class
31 * Wrapper for the JIRA Rest Api
32 * https://docs.atlassian.com/jira/REST/6.4.8/
33 */
34var JiraApi = /*#__PURE__*/function () {
35 /**
36 * @constructor
37 * @function
38 * @param {JiraApiOptions} options
39 */
40 function JiraApi(options) {
41 (0, _classCallCheck2["default"])(this, JiraApi);
42 this.protocol = options.protocol || 'http';
43 this.host = options.host;
44 this.port = options.port || null;
45 this.apiVersion = options.apiVersion || '2';
46 this.base = options.base || '';
47 this.intermediatePath = options.intermediatePath;
48 this.strictSSL = options.hasOwnProperty('strictSSL') ? options.strictSSL : true; // This is so we can fake during unit tests
49
50 this.request = options.request || _requestPromise["default"];
51 this.webhookVersion = options.webHookVersion || '1.0';
52 this.greenhopperVersion = options.greenhopperVersion || '1.0';
53 this.baseOptions = {};
54
55 if (options.ca) {
56 this.baseOptions.ca = options.ca;
57 }
58
59 if (options.oauth && options.oauth.consumer_key && options.oauth.access_token) {
60 this.baseOptions.oauth = {
61 consumer_key: options.oauth.consumer_key,
62 consumer_secret: options.oauth.consumer_secret,
63 token: options.oauth.access_token,
64 token_secret: options.oauth.access_token_secret,
65 signature_method: options.oauth.signature_method || 'RSA-SHA1'
66 };
67 } else if (options.bearer) {
68 this.baseOptions.auth = {
69 user: '',
70 pass: '',
71 sendImmediately: true,
72 bearer: options.bearer
73 };
74 } else if (options.username && options.password) {
75 this.baseOptions.auth = {
76 user: options.username,
77 pass: options.password
78 };
79 }
80
81 if (options.timeout) {
82 this.baseOptions.timeout = options.timeout;
83 }
84 }
85 /**
86 * @typedef JiraApiOptions
87 * @type {object}
88 * @property {string} [protocol=http] - What protocol to use to connect to
89 * jira? Ex: http|https
90 * @property {string} host - What host is this tool connecting to for the jira
91 * instance? Ex: jira.somehost.com
92 * @property {string} [port] - What port is this tool connecting to jira with? Only needed for
93 * none standard ports. Ex: 8080, 3000, etc
94 * @property {string} [username] - Specify a username for this tool to authenticate all
95 * requests with.
96 * @property {string} [password] - Specify a password for this tool to authenticate all
97 * requests with. Cloud users need to generate an [API token](https://confluence.atlassian.com/cloud/api-tokens-938839638.html) for this value.
98 * @property {string} [apiVersion=2] - What version of the jira rest api is the instance the
99 * tool is connecting to?
100 * @property {string} [base] - What other url parts exist, if any, before the rest/api/
101 * section?
102 * @property {string} [intermediatePath] - If specified, overwrites the default rest/api/version
103 * section of the uri
104 * @property {boolean} [strictSSL=true] - Does this tool require each request to be
105 * authenticated? Defaults to true.
106 * @property {function} [request] - What method does this tool use to make its requests?
107 * Defaults to request from request-promise
108 * @property {number} [timeout] - Integer containing the number of milliseconds to wait for a
109 * server to send response headers (and start the response body) before aborting the request. Note
110 * that if the underlying TCP connection cannot be established, the OS-wide TCP connection timeout
111 * will overrule the timeout option ([the default in Linux can be anywhere from 20-120 *
112 * seconds](http://www.sekuda.com/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout)).
113 * @property {string} [webhookVersion=1.0] - What webhook version does this api wrapper need to
114 * hit?
115 * @property {string} [greenhopperVersion=1.0] - What webhook version does this api wrapper need
116 * to hit?
117 * @property {string} [ca] - Specify a CA certificate
118 * @property {OAuth} [oauth] - Specify an OAuth object for this tool to authenticate all requests
119 * using OAuth.
120 * @property {string} [bearer] - Specify an OAuth bearer token to authenticate all requests with.
121 */
122
123 /**
124 * @typedef OAuth
125 * @type {object}
126 * @property {string} consumer_key - The consumer entered in Jira Preferences.
127 * @property {string} consumer_secret - The private RSA file.
128 * @property {string} access_token - The generated access token.
129 * @property {string} access_token_secret - The generated access toke secret.
130 * @property {string} signature_method [signature_method=RSA-SHA1] - OAuth signurate methode
131 * Possible values RSA-SHA1, HMAC-SHA1, PLAINTEXT. Jira Cloud supports only RSA-SHA1.
132 */
133
134 /**
135 * @typedef {object} UriOptions
136 * @property {string} pathname - The url after the specific functions path
137 * @property {object} [query] - An object of all query parameters
138 * @property {string} [intermediatePath] - Overwrites with specified path
139 */
140
141 /**
142 * @name makeRequestHeader
143 * @function
144 * Creates a requestOptions object based on the default template for one
145 * @param {string} uri
146 * @param {object} [options] - an object containing fields and formatting how the
147 */
148
149
150 (0, _createClass2["default"])(JiraApi, [{
151 key: "makeRequestHeader",
152 value: function makeRequestHeader(uri) {
153 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
154 return _objectSpread({
155 rejectUnauthorized: this.strictSSL,
156 method: options.method || 'GET',
157 uri: uri,
158 json: true
159 }, options);
160 }
161 /**
162 * @typedef makeRequestHeaderOptions
163 * @type {object}
164 * @property {string} [method] - HTTP Request Method. ie GET, POST, PUT, DELETE
165 */
166
167 /**
168 * @name makeUri
169 * @function
170 * Creates a URI object for a given pathname
171 * @param {object} [options] - an object containing path information
172 */
173
174 }, {
175 key: "makeUri",
176 value: function makeUri(_ref) {
177 var pathname = _ref.pathname,
178 query = _ref.query,
179 intermediatePath = _ref.intermediatePath,
180 _ref$encode = _ref.encode,
181 encode = _ref$encode === void 0 ? false : _ref$encode;
182 var intermediateToUse = this.intermediatePath || intermediatePath;
183 var tempPath = intermediateToUse || "/rest/api/".concat(this.apiVersion);
184
185 var uri = _url["default"].format({
186 protocol: this.protocol,
187 hostname: this.host,
188 port: this.port,
189 pathname: "".concat(this.base).concat(tempPath).concat(pathname),
190 query: query
191 });
192
193 return encode ? encodeURI(uri) : decodeURIComponent(uri);
194 }
195 /**
196 * @typedef makeUriOptions
197 * @type {object}
198 * @property {string} pathname - The url after the /rest/api/version
199 * @property {object} query - a query object
200 * @property {string} intermediatePath - If specified will overwrite the /rest/api/version section
201 */
202
203 /**
204 * @name makeWebhookUri
205 * @function
206 * Creates a URI object for a given pathName
207 * @param {object} [options] - An options object specifying uri information
208 */
209
210 }, {
211 key: "makeWebhookUri",
212 value: function makeWebhookUri(_ref2) {
213 var pathname = _ref2.pathname,
214 intermediatePath = _ref2.intermediatePath;
215 var intermediateToUse = this.intermediatePath || intermediatePath;
216 var tempPath = intermediateToUse || "/rest/webhooks/".concat(this.webhookVersion);
217
218 var uri = _url["default"].format({
219 protocol: this.protocol,
220 hostname: this.host,
221 port: this.port,
222 pathname: "".concat(this.base).concat(tempPath).concat(pathname)
223 });
224
225 return decodeURIComponent(uri);
226 }
227 /**
228 * @typedef makeWebhookUriOptions
229 * @type {object}
230 * @property {string} pathname - The url after the /rest/webhooks
231 * @property {string} intermediatePath - If specified will overwrite the /rest/webhooks section
232 */
233
234 /**
235 * @name makeSprintQueryUri
236 * @function
237 * Creates a URI object for a given pathName
238 * @param {object} [options] - The url after the /rest/
239 */
240
241 }, {
242 key: "makeSprintQueryUri",
243 value: function makeSprintQueryUri(_ref3) {
244 var pathname = _ref3.pathname,
245 query = _ref3.query,
246 intermediatePath = _ref3.intermediatePath;
247 var intermediateToUse = this.intermediatePath || intermediatePath;
248 var tempPath = intermediateToUse || "/rest/greenhopper/".concat(this.greenhopperVersion);
249
250 var uri = _url["default"].format({
251 protocol: this.protocol,
252 hostname: this.host,
253 port: this.port,
254 pathname: "".concat(this.base).concat(tempPath).concat(pathname),
255 query: query
256 });
257
258 return decodeURIComponent(uri);
259 }
260 /**
261 * @typedef makeSprintQueryUriOptions
262 * @type {object}
263 * @property {string} pathname - The url after the /rest/api/version
264 * @property {object} query - a query object
265 * @property {string} intermediatePath - will overwrite the /rest/greenhopper/version section
266 */
267
268 /**
269 * @typedef makeDevStatusUri
270 * @function
271 * Creates a URI object for a given pathname
272 * @arg {pathname, query, intermediatePath} obj1
273 * @param {string} pathname obj1.pathname - The url after the /rest/api/version
274 * @param {object} query obj1.query - a query object
275 * @param {string} intermediatePath obj1.intermediatePath - If specified will overwrite the
276 * /rest/dev-status/latest/issue/detail section
277 */
278
279 }, {
280 key: "makeDevStatusUri",
281 value: function makeDevStatusUri(_ref4) {
282 var pathname = _ref4.pathname,
283 query = _ref4.query,
284 intermediatePath = _ref4.intermediatePath;
285 var intermediateToUse = this.intermediatePath || intermediatePath;
286 var tempPath = intermediateToUse || '/rest/dev-status/latest/issue';
287
288 var uri = _url["default"].format({
289 protocol: this.protocol,
290 hostname: this.host,
291 port: this.port,
292 pathname: "".concat(this.base).concat(tempPath).concat(pathname),
293 query: query
294 });
295
296 return decodeURIComponent(uri);
297 }
298 /**
299 * @name makeAgile1Uri
300 * @function
301 * Creates a URI object for a given pathname
302 * @param {UriOptions} object
303 */
304
305 }, {
306 key: "makeAgileUri",
307 value: function makeAgileUri(object) {
308 var intermediateToUse = this.intermediatePath || object.intermediatePath;
309 var tempPath = intermediateToUse || '/rest/agile/1.0';
310
311 var uri = _url["default"].format({
312 protocol: this.protocol,
313 hostname: this.host,
314 port: this.port,
315 pathname: "".concat(this.base).concat(tempPath).concat(object.pathname),
316 query: object.query
317 });
318
319 return decodeURIComponent(uri);
320 }
321 /**
322 * @name doRequest
323 * @function
324 * Does a request based on the requestOptions object
325 * @param {object} requestOptions - fields on this object get posted as a request header for
326 * requests to jira
327 */
328
329 }, {
330 key: "doRequest",
331 value: function () {
332 var _doRequest = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(requestOptions) {
333 var options, response;
334 return _regenerator["default"].wrap(function _callee$(_context) {
335 while (1) {
336 switch (_context.prev = _context.next) {
337 case 0:
338 options = _objectSpread(_objectSpread({}, this.baseOptions), requestOptions);
339 _context.next = 3;
340 return this.request(options);
341
342 case 3:
343 response = _context.sent;
344
345 if (!response) {
346 _context.next = 7;
347 break;
348 }
349
350 if (!(Array.isArray(response.errorMessages) && response.errorMessages.length > 0)) {
351 _context.next = 7;
352 break;
353 }
354
355 throw new Error(response.errorMessages.join(', '));
356
357 case 7:
358 return _context.abrupt("return", response);
359
360 case 8:
361 case "end":
362 return _context.stop();
363 }
364 }
365 }, _callee, this);
366 }));
367
368 function doRequest(_x) {
369 return _doRequest.apply(this, arguments);
370 }
371
372 return doRequest;
373 }()
374 /**
375 * @name findIssue
376 * @function
377 * Find an issue in jira
378 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290709)
379 * @param {string} issueNumber - The issue number to search for including the project key
380 * @param {string} expand - The resource expansion to return additional fields in the response
381 * @param {string} fields - Comma separated list of field ids or keys to retrieve
382 * @param {string} properties - Comma separated list of properties to retrieve
383 * @param {boolean} fieldsByKeys - False by default, used to retrieve fields by key instead of id
384 */
385
386 }, {
387 key: "findIssue",
388 value: function findIssue(issueNumber, expand, fields, properties, fieldsByKeys) {
389 return this.doRequest(this.makeRequestHeader(this.makeUri({
390 pathname: "/issue/".concat(issueNumber),
391 query: {
392 expand: expand || '',
393 fields: fields || '*all',
394 properties: properties || '*all',
395 fieldsByKeys: fieldsByKeys || false
396 }
397 })));
398 }
399 /**
400 * @name downloadAttachment
401 * @function
402 * Download an attachment
403 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id288524)
404 * @param {object} attachment - the attachment
405 */
406
407 }, {
408 key: "downloadAttachment",
409 value: function downloadAttachment(attachment) {
410 return this.doRequest(this.makeRequestHeader(this.makeUri({
411 pathname: "/attachment/".concat(attachment.id, "/").concat(attachment.filename),
412 intermediatePath: '/secure',
413 encode: true
414 }), {
415 json: false,
416 encoding: null
417 }));
418 }
419 /**
420 * @name getUnresolvedIssueCount
421 * @function
422 * Get the unresolved issue count
423 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id288524)
424 * @param {string} version - the version of your product you want to find the unresolved
425 * issues of.
426 */
427
428 }, {
429 key: "getUnresolvedIssueCount",
430 value: function () {
431 var _getUnresolvedIssueCount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(version) {
432 var requestHeaders, response;
433 return _regenerator["default"].wrap(function _callee2$(_context2) {
434 while (1) {
435 switch (_context2.prev = _context2.next) {
436 case 0:
437 requestHeaders = this.makeRequestHeader(this.makeUri({
438 pathname: "/version/".concat(version, "/unresolvedIssueCount")
439 }));
440 _context2.next = 3;
441 return this.doRequest(requestHeaders);
442
443 case 3:
444 response = _context2.sent;
445 return _context2.abrupt("return", response.issuesUnresolvedCount);
446
447 case 5:
448 case "end":
449 return _context2.stop();
450 }
451 }
452 }, _callee2, this);
453 }));
454
455 function getUnresolvedIssueCount(_x2) {
456 return _getUnresolvedIssueCount.apply(this, arguments);
457 }
458
459 return getUnresolvedIssueCount;
460 }()
461 /**
462 * @name getProject
463 * @function
464 * Get the Project by project key
465 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id289232)
466 * @param {string} project - key for the project
467 */
468
469 }, {
470 key: "getProject",
471 value: function getProject(project) {
472 return this.doRequest(this.makeRequestHeader(this.makeUri({
473 pathname: "/project/".concat(project)
474 })));
475 }
476 /**
477 * @name createProject
478 * @function
479 * Create a new Project
480 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#api/2/project-createProject)
481 * @param {object} project - with specs
482 */
483
484 }, {
485 key: "createProject",
486 value: function createProject(project) {
487 return this.doRequest(this.makeRequestHeader(this.makeUri({
488 pathname: '/project/'
489 }), {
490 method: 'POST',
491 body: project
492 }));
493 }
494 /** Find the Rapid View for a specified project
495 * @name findRapidView
496 * @function
497 * @param {string} projectName - name for the project
498 */
499
500 }, {
501 key: "findRapidView",
502 value: function () {
503 var _findRapidView = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(projectName) {
504 var response, rapidViewResult;
505 return _regenerator["default"].wrap(function _callee3$(_context3) {
506 while (1) {
507 switch (_context3.prev = _context3.next) {
508 case 0:
509 _context3.next = 2;
510 return this.doRequest(this.makeRequestHeader(this.makeSprintQueryUri({
511 pathname: '/rapidviews/list'
512 })));
513
514 case 2:
515 response = _context3.sent;
516
517 if (!(typeof projectName === 'undefined' || projectName === null)) {
518 _context3.next = 5;
519 break;
520 }
521
522 return _context3.abrupt("return", response.views);
523
524 case 5:
525 rapidViewResult = response.views.find(function (x) {
526 return x.name.toLowerCase() === projectName.toLowerCase();
527 });
528 return _context3.abrupt("return", rapidViewResult);
529
530 case 7:
531 case "end":
532 return _context3.stop();
533 }
534 }
535 }, _callee3, this);
536 }));
537
538 function findRapidView(_x3) {
539 return _findRapidView.apply(this, arguments);
540 }
541
542 return findRapidView;
543 }()
544 /** Get the most recent sprint for a given rapidViewId
545 * @name getLastSprintForRapidView
546 * @function
547 * @param {string} rapidViewId - the id for the rapid view
548 */
549
550 }, {
551 key: "getLastSprintForRapidView",
552 value: function () {
553 var _getLastSprintForRapidView = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(rapidViewId) {
554 var response;
555 return _regenerator["default"].wrap(function _callee4$(_context4) {
556 while (1) {
557 switch (_context4.prev = _context4.next) {
558 case 0:
559 _context4.next = 2;
560 return this.doRequest(this.makeRequestHeader(this.makeSprintQueryUri({
561 pathname: "/sprintquery/".concat(rapidViewId)
562 })));
563
564 case 2:
565 response = _context4.sent;
566 return _context4.abrupt("return", response.sprints.pop());
567
568 case 4:
569 case "end":
570 return _context4.stop();
571 }
572 }
573 }, _callee4, this);
574 }));
575
576 function getLastSprintForRapidView(_x4) {
577 return _getLastSprintForRapidView.apply(this, arguments);
578 }
579
580 return getLastSprintForRapidView;
581 }()
582 /** Get the issues for a rapidView / sprint
583 * @name getSprintIssues
584 * @function
585 * @param {string} rapidViewId - the id for the rapid view
586 * @param {string} sprintId - the id for the sprint
587 */
588
589 }, {
590 key: "getSprintIssues",
591 value: function getSprintIssues(rapidViewId, sprintId) {
592 return this.doRequest(this.makeRequestHeader(this.makeSprintQueryUri({
593 pathname: '/rapid/charts/sprintreport',
594 query: {
595 rapidViewId: rapidViewId,
596 sprintId: sprintId
597 }
598 })));
599 }
600 /** Get a list of Sprints belonging to a Rapid View
601 * @name listSprints
602 * @function
603 * @param {string} rapidViewId - the id for the rapid view
604 */
605
606 }, {
607 key: "listSprints",
608 value: function listSprints(rapidViewId) {
609 return this.doRequest(this.makeRequestHeader(this.makeSprintQueryUri({
610 pathname: "/sprintquery/".concat(rapidViewId)
611 })));
612 }
613 /** Add an issue to the project's current sprint
614 * @name addIssueToSprint
615 * @function
616 * @param {string} issueId - the id of the existing issue
617 * @param {string} sprintId - the id of the sprint to add it to
618 */
619
620 }, {
621 key: "addIssueToSprint",
622 value: function addIssueToSprint(issueId, sprintId) {
623 return this.doRequest(this.makeRequestHeader(this.makeUri({
624 pathname: "/sprint/".concat(sprintId, "/issues/add")
625 }), {
626 method: 'PUT',
627 followAllRedirects: true,
628 body: {
629 issueKeys: [issueId]
630 }
631 }));
632 }
633 /** Create an issue link between two issues
634 * @name issueLink
635 * @function
636 * @param {object} link - a link object formatted how the Jira API specifies
637 */
638
639 }, {
640 key: "issueLink",
641 value: function issueLink(link) {
642 return this.doRequest(this.makeRequestHeader(this.makeUri({
643 pathname: '/issueLink'
644 }), {
645 method: 'POST',
646 followAllRedirects: true,
647 body: link
648 }));
649 }
650 /** List all issue link types jira knows about
651 * [Jira Doc](https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/issueLinkType-getIssueLinkTypes)
652 * @name listIssueLinkTypes
653 * @function
654 */
655
656 }, {
657 key: "listIssueLinkTypes",
658 value: function listIssueLinkTypes() {
659 return this.doRequest(this.makeRequestHeader(this.makeUri({
660 pathname: '/issueLinkType'
661 })));
662 }
663 /** Retrieves the remote links associated with the given issue.
664 * @name getRemoteLinks
665 * @function
666 * @param {string} issueNumber - the issue number to find remote links for.
667 */
668
669 }, {
670 key: "getRemoteLinks",
671 value: function getRemoteLinks(issueNumber) {
672 return this.doRequest(this.makeRequestHeader(this.makeUri({
673 pathname: "/issue/".concat(issueNumber, "/remotelink")
674 })));
675 }
676 /**
677 * @name createRemoteLink
678 * @function
679 * Creates a remote link associated with the given issue.
680 * @param {string} issueNumber - The issue number to create the remotelink under
681 * @param {object} remoteLink - the remotelink object as specified by the Jira API
682 */
683
684 }, {
685 key: "createRemoteLink",
686 value: function createRemoteLink(issueNumber, remoteLink) {
687 return this.doRequest(this.makeRequestHeader(this.makeUri({
688 pathname: "/issue/".concat(issueNumber, "/remotelink")
689 }), {
690 method: 'POST',
691 body: remoteLink
692 }));
693 }
694 /** Get Versions for a project
695 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id289653)
696 * @name getVersions
697 * @function
698 * @param {string} project - A project key to get versions for
699 */
700
701 }, {
702 key: "getVersions",
703 value: function getVersions(project) {
704 return this.doRequest(this.makeRequestHeader(this.makeUri({
705 pathname: "/project/".concat(project, "/versions")
706 })));
707 }
708 /** Get details of single Version in project
709 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/version-getVersion)
710 * @name getVersion
711 * @function
712 * @param {string} version - The id of this version
713 */
714
715 }, {
716 key: "getVersion",
717 value: function getVersion(version) {
718 return this.doRequest(this.makeRequestHeader(this.makeUri({
719 pathname: "/version/".concat(version)
720 })));
721 }
722 /** Create a version
723 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id288232)
724 * @name createVersion
725 * @function
726 * @param {object} version - an object of the new version
727 */
728
729 }, {
730 key: "createVersion",
731 value: function createVersion(version) {
732 return this.doRequest(this.makeRequestHeader(this.makeUri({
733 pathname: '/version'
734 }), {
735 method: 'POST',
736 followAllRedirects: true,
737 body: version
738 }));
739 }
740 /** Update a version
741 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#d2e510)
742 * @name updateVersion
743 * @function
744 * @param {object} version - an new object of the version to update
745 */
746
747 }, {
748 key: "updateVersion",
749 value: function updateVersion(version) {
750 return this.doRequest(this.makeRequestHeader(this.makeUri({
751 pathname: "/version/".concat(version.id)
752 }), {
753 method: 'PUT',
754 followAllRedirects: true,
755 body: version
756 }));
757 }
758 /** Delete a version
759 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#api/2/version-delete)
760 * @name deleteVersion
761 * @function
762 * @param {string} versionId - the ID of the version to delete
763 * @param {string} moveFixIssuesToId - when provided, existing fixVersions will be moved
764 * to this ID. Otherwise, the deleted version will be removed from all
765 * issue fixVersions.
766 * @param {string} moveAffectedIssuesToId - when provided, existing affectedVersions will
767 * be moved to this ID. Otherwise, the deleted version will be removed
768 * from all issue affectedVersions.
769 */
770
771 }, {
772 key: "deleteVersion",
773 value: function deleteVersion(versionId, moveFixIssuesToId, moveAffectedIssuesToId) {
774 return this.doRequest(this.makeRequestHeader(this.makeUri({
775 pathname: "/version/".concat(versionId)
776 }), {
777 method: 'DELETE',
778 followAllRedirects: true,
779 qs: {
780 moveFixIssuesTo: moveFixIssuesToId,
781 moveAffectedIssuesTo: moveAffectedIssuesToId
782 }
783 }));
784 }
785 /** Move version
786 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/version-moveVersion)
787 * @name moveVersion
788 * @function
789 * @param {string} versionId - the ID of the version to delete
790 * @param {string} position - an object of the new position
791 */
792
793 }, {
794 key: "moveVersion",
795 value: function moveVersion(versionId, position) {
796 return this.doRequest(this.makeRequestHeader(this.makeUri({
797 pathname: "/version/".concat(versionId, "/move")
798 }), {
799 method: 'POST',
800 followAllRedirects: true,
801 body: position
802 }));
803 }
804 /** Pass a search query to Jira
805 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#d2e4424)
806 * @name searchJira
807 * @function
808 * @param {string} searchString - jira query string in JQL
809 * @param {object} optional - object containing any of the following properties
810 * @param {integer} [optional.startAt=0]: optional starting index number
811 * @param {integer} [optional.maxResults=50]: optional The maximum number of items to
812 * return per page. To manage page size, Jira may return fewer items per
813 * page where a large number of fields are requested.
814 * @param {array} [optional.fields]: optional array of string names of desired fields
815 * @param {array} [optional.expand]: optional array of string names of desired expand nodes
816 */
817
818 }, {
819 key: "searchJira",
820 value: function searchJira(searchString) {
821 var optional = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
822 return this.doRequest(this.makeRequestHeader(this.makeUri({
823 pathname: '/search'
824 }), {
825 method: 'POST',
826 followAllRedirects: true,
827 body: _objectSpread({
828 jql: searchString
829 }, optional)
830 }));
831 }
832 /** Create a Jira user
833 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/user-createUser)
834 * @name createUser
835 * @function
836 * @param {object} user - Properly Formatted User object
837 */
838
839 }, {
840 key: "createUser",
841 value: function createUser(user) {
842 return this.doRequest(this.makeRequestHeader(this.makeUri({
843 pathname: '/user'
844 }), {
845 method: 'POST',
846 followAllRedirects: true,
847 body: user
848 }));
849 }
850 /** Search user on Jira
851 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#d2e3756)
852 * @name searchUsers
853 * @function
854 * @param {SearchUserOptions} options
855 */
856
857 }, {
858 key: "searchUsers",
859 value: function searchUsers(_ref5) {
860 var username = _ref5.username,
861 query = _ref5.query,
862 startAt = _ref5.startAt,
863 maxResults = _ref5.maxResults,
864 includeActive = _ref5.includeActive,
865 includeInactive = _ref5.includeInactive;
866 return this.doRequest(this.makeRequestHeader(this.makeUri({
867 pathname: '/user/search',
868 query: {
869 username: username,
870 query: query,
871 startAt: startAt || 0,
872 maxResults: maxResults || 50,
873 includeActive: includeActive || true,
874 includeInactive: includeInactive || false
875 }
876 }), {
877 followAllRedirects: true
878 }));
879 }
880 /**
881 * @typedef SearchUserOptions
882 * @type {object}
883 * @property {string} username - (DEPRECATED) A query string used to search username, name or
884 * e-mail address
885 * @property {string} query - A query string that is matched against user attributes
886 * (displayName, and emailAddress) to find relevant users. The string can match the prefix of
887 * the attribute's value. For example, query=john matches a user with a displayName of John
888 * Smith and a user with an emailAddress of johnson@example.com. Required, unless accountId
889 * or property is specified.
890 * @property {integer} [startAt=0] - The index of the first user to return (0-based)
891 * @property {integer} [maxResults=50] - The maximum number of users to return
892 * @property {boolean} [includeActive=true] - If true, then active users are included
893 * in the results
894 * @property {boolean} [includeInactive=false] - If true, then inactive users
895 * are included in the results
896 */
897
898 /** Get all users in group on Jira
899 * @name getUsersInGroup
900 * @function
901 * @param {string} groupname - A query string used to search users in group
902 * @param {integer} [startAt=0] - The index of the first user to return (0-based)
903 * @param {integer} [maxResults=50] - The maximum number of users to return (defaults to 50).
904 */
905
906 }, {
907 key: "getUsersInGroup",
908 value: function getUsersInGroup(groupname) {
909 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
910 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
911 return this.doRequest(this.makeRequestHeader(this.makeUri({
912 pathname: '/group',
913 query: {
914 groupname: groupname,
915 expand: "users[".concat(startAt, ":").concat(maxResults, "]")
916 }
917 }), {
918 followAllRedirects: true
919 }));
920 }
921 /** Get issues related to a user
922 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id296043)
923 * @name getUsersIssues
924 * @function
925 * @param {string} username - username of user to search for
926 * @param {boolean} open - determines if only open issues should be returned
927 */
928
929 }, {
930 key: "getUsersIssues",
931 value: function getUsersIssues(username, open) {
932 var openJql = open ? ' AND status in (Open, \'In Progress\', Reopened)' : '';
933 return this.searchJira("assignee = ".concat(username.replace('@', "\\u0040")).concat(openJql), {});
934 }
935 /** Returns a user.
936 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-user-get)
937 * @name getUser
938 * @function
939 * @param {string} accountId - The accountId of user to search for
940 * @param {string} expand - The expand for additional info (groups,applicationRoles)
941 */
942
943 }, {
944 key: "getUser",
945 value: function getUser(accountId, expand) {
946 return this.doRequest(this.makeRequestHeader(this.makeUri({
947 pathname: '/user',
948 query: {
949 accountId: accountId,
950 expand: expand
951 }
952 })));
953 }
954 /** Returns a list of all (active and inactive) users.
955 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-users-search-get)
956 * @name getUsers
957 * @function
958 * @param {integer} [startAt=0] - The index of the first user to return (0-based)
959 * @param {integer} [maxResults=50] - The maximum number of users to return (defaults to 50).
960 */
961
962 }, {
963 key: "getUsers",
964 value: function getUsers() {
965 var startAt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
966 var maxResults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
967 return this.doRequest(this.makeRequestHeader(this.makeUri({
968 pathname: '/users',
969 query: {
970 startAt: startAt,
971 maxResults: maxResults
972 }
973 })));
974 }
975 /** Add issue to Jira
976 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290028)
977 * @name addNewIssue
978 * @function
979 * @param {object} issue - Properly Formatted Issue object
980 */
981
982 }, {
983 key: "addNewIssue",
984 value: function addNewIssue(issue) {
985 return this.doRequest(this.makeRequestHeader(this.makeUri({
986 pathname: '/issue'
987 }), {
988 method: 'POST',
989 followAllRedirects: true,
990 body: issue
991 }));
992 }
993 /** Add a user as a watcher on an issue
994 * @name addWatcher
995 * @function
996 * @param {string} issueKey - the key of the existing issue
997 * @param {string} username - the jira username to add as a watcher to the issue
998 */
999
1000 }, {
1001 key: "addWatcher",
1002 value: function addWatcher(issueKey, username) {
1003 return this.doRequest(this.makeRequestHeader(this.makeUri({
1004 pathname: "/issue/".concat(issueKey, "/watchers")
1005 }), {
1006 method: 'POST',
1007 followAllRedirects: true,
1008 body: username
1009 }));
1010 }
1011 /** Change an assignee on an issue
1012 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-assign)
1013 * @name assignee
1014 * @function
1015 * @param {string} issueKey - the key of the existing issue
1016 * @param {string} assigneeName - the jira username to add as a new assignee to the issue
1017 */
1018
1019 }, {
1020 key: "updateAssignee",
1021 value: function updateAssignee(issueKey, assigneeName) {
1022 return this.doRequest(this.makeRequestHeader(this.makeUri({
1023 pathname: "/issue/".concat(issueKey, "/assignee")
1024 }), {
1025 method: 'PUT',
1026 followAllRedirects: true,
1027 body: {
1028 name: assigneeName
1029 }
1030 }));
1031 }
1032 /** Change an assignee on an issue
1033 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-assignee-put)
1034 * @name updateAssigneeWithId
1035 * @function
1036 * @param {string} issueKey - the key of the existing issue
1037 * @param {string} userId - the jira username to add as a new assignee to the issue
1038 */
1039
1040 }, {
1041 key: "updateAssigneeWithId",
1042 value: function updateAssigneeWithId(issueKey, userId) {
1043 return this.doRequest(this.makeRequestHeader(this.makeUri({
1044 pathname: "/issue/".concat(issueKey, "/assignee")
1045 }), {
1046 method: 'PUT',
1047 followAllRedirects: true,
1048 body: {
1049 accountId: userId
1050 }
1051 }));
1052 }
1053 /** Delete issue from Jira
1054 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290791)
1055 * @name deleteIssue
1056 * @function
1057 * @param {string} issueId - the Id of the issue to delete
1058 */
1059
1060 }, {
1061 key: "deleteIssue",
1062 value: function deleteIssue(issueId) {
1063 return this.doRequest(this.makeRequestHeader(this.makeUri({
1064 pathname: "/issue/".concat(issueId)
1065 }), {
1066 method: 'DELETE',
1067 followAllRedirects: true
1068 }));
1069 }
1070 /** Update issue in Jira
1071 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290878)
1072 * @name updateIssue
1073 * @function
1074 * @param {string} issueId - the Id of the issue to update
1075 * @param {object} issueUpdate - update Object as specified by the rest api
1076 * @param {object} query - adds parameters to the query string
1077 */
1078
1079 }, {
1080 key: "updateIssue",
1081 value: function updateIssue(issueId, issueUpdate) {
1082 var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1083 return this.doRequest(this.makeRequestHeader(this.makeUri({
1084 pathname: "/issue/".concat(issueId),
1085 query: query
1086 }), {
1087 body: issueUpdate,
1088 method: 'PUT',
1089 followAllRedirects: true
1090 }));
1091 }
1092 /** List Components
1093 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
1094 * @name listComponents
1095 * @function
1096 * @param {string} project - key for the project
1097 */
1098
1099 }, {
1100 key: "listComponents",
1101 value: function listComponents(project) {
1102 return this.doRequest(this.makeRequestHeader(this.makeUri({
1103 pathname: "/project/".concat(project, "/components")
1104 })));
1105 }
1106 /** Add component to Jira
1107 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290028)
1108 * @name addNewComponent
1109 * @function
1110 * @param {object} component - Properly Formatted Component
1111 */
1112
1113 }, {
1114 key: "addNewComponent",
1115 value: function addNewComponent(component) {
1116 return this.doRequest(this.makeRequestHeader(this.makeUri({
1117 pathname: '/component'
1118 }), {
1119 method: 'POST',
1120 followAllRedirects: true,
1121 body: component
1122 }));
1123 }
1124 /** Update Jira component
1125 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/component-updateComponent)
1126 * @name updateComponent
1127 * @function
1128 * @param {string} componentId - the Id of the component to update
1129 * @param {object} component - Properly Formatted Component
1130 */
1131
1132 }, {
1133 key: "updateComponent",
1134 value: function updateComponent(componentId, component) {
1135 return this.doRequest(this.makeRequestHeader(this.makeUri({
1136 pathname: "/component/".concat(componentId)
1137 }), {
1138 method: 'PUT',
1139 followAllRedirects: true,
1140 body: component
1141 }));
1142 }
1143 /** Delete component from Jira
1144 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-api-2-component-id-delete)
1145 * @name deleteComponent
1146 * @function
1147 * @param {string} id - The ID of the component.
1148 * @param {string} moveIssuesTo - The ID of the component to replace the deleted component.
1149 * If this value is null no replacement is made.
1150 */
1151
1152 }, {
1153 key: "deleteComponent",
1154 value: function deleteComponent(id, moveIssuesTo) {
1155 return this.doRequest(this.makeRequestHeader(this.makeUri({
1156 pathname: "/component/".concat(id)
1157 }), {
1158 method: 'DELETE',
1159 followAllRedirects: true,
1160 qs: moveIssuesTo ? {
1161 moveIssuesTo: moveIssuesTo
1162 } : null
1163 }));
1164 }
1165 /** Get count of issues assigned to the component.
1166 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-component-id-relatedIssueCounts-get)
1167 * @name relatedIssueCounts
1168 * @function
1169 * @param {string} id - Component Id.
1170 */
1171
1172 }, {
1173 key: "relatedIssueCounts",
1174 value: function relatedIssueCounts(id) {
1175 return this.doRequest(this.makeRequestHeader(this.makeUri({
1176 pathname: "/component/".concat(id, "/relatedIssueCounts")
1177 })));
1178 }
1179 /** Create custom Jira field
1180 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/field-createCustomField)
1181 * @name createCustomField
1182 * @function
1183 * @param {object} field - Properly formatted Field object
1184 */
1185
1186 }, {
1187 key: "createCustomField",
1188 value: function createCustomField(field) {
1189 return this.doRequest(this.makeRequestHeader(this.makeUri({
1190 pathname: '/field'
1191 }), {
1192 method: 'POST',
1193 followAllRedirects: true,
1194 body: field
1195 }));
1196 }
1197 /** List all fields custom and not that jira knows about.
1198 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
1199 * @name listFields
1200 * @function
1201 */
1202
1203 }, {
1204 key: "listFields",
1205 value: function listFields() {
1206 return this.doRequest(this.makeRequestHeader(this.makeUri({
1207 pathname: '/field'
1208 })));
1209 }
1210 /** Add an option for a select list issue field.
1211 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/field/{fieldKey}/option-createOption)
1212 * @name createFieldOption
1213 * @function
1214 * @param {string} fieldKey - the key of the select list field
1215 * @param {object} option - properly formatted Option object
1216 */
1217
1218 }, {
1219 key: "createFieldOption",
1220 value: function createFieldOption(fieldKey, option) {
1221 return this.doRequest(this.makeRequestHeader(this.makeUri({
1222 pathname: "/field/".concat(fieldKey, "/option")
1223 }), {
1224 method: 'POST',
1225 followAllRedirects: true,
1226 body: option
1227 }));
1228 }
1229 /** Returns all options defined for a select list issue field.
1230 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/field/{fieldKey}/option-getAllOptions)
1231 * @name listFieldOptions
1232 * @function
1233 * @param {string} fieldKey - the key of the select list field
1234 */
1235
1236 }, {
1237 key: "listFieldOptions",
1238 value: function listFieldOptions(fieldKey) {
1239 return this.doRequest(this.makeRequestHeader(this.makeUri({
1240 pathname: "/field/".concat(fieldKey, "/option")
1241 })));
1242 }
1243 /** Creates or updates an option for a select list issue field.
1244 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/field/{fieldKey}/option-putOption)
1245 * @name upsertFieldOption
1246 * @function
1247 * @param {string} fieldKey - the key of the select list field
1248 * @param {string} optionId - the id of the modified option
1249 * @param {object} option - properly formatted Option object
1250 */
1251
1252 }, {
1253 key: "upsertFieldOption",
1254 value: function upsertFieldOption(fieldKey, optionId, option) {
1255 return this.doRequest(this.makeRequestHeader(this.makeUri({
1256 pathname: "/field/".concat(fieldKey, "/option/").concat(optionId)
1257 }), {
1258 method: 'PUT',
1259 followAllRedirects: true,
1260 body: option
1261 }));
1262 }
1263 /** Returns an option for a select list issue field.
1264 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/field/{fieldKey}/option-getOption)
1265 * @name getFieldOption
1266 * @function
1267 * @param {string} fieldKey - the key of the select list field
1268 * @param {string} optionId - the id of the option
1269 */
1270
1271 }, {
1272 key: "getFieldOption",
1273 value: function getFieldOption(fieldKey, optionId) {
1274 return this.doRequest(this.makeRequestHeader(this.makeUri({
1275 pathname: "/field/".concat(fieldKey, "/option/").concat(optionId)
1276 })));
1277 }
1278 /** Deletes an option from a select list issue field.
1279 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#api/2/field/{fieldKey}/option-delete)
1280 * @name deleteFieldOption
1281 * @function
1282 * @param {string} fieldKey - the key of the select list field
1283 * @param {string} optionId - the id of the deleted option
1284 */
1285
1286 }, {
1287 key: "deleteFieldOption",
1288 value: function deleteFieldOption(fieldKey, optionId) {
1289 return this.doRequest(this.makeRequestHeader(this.makeUri({
1290 pathname: "/field/".concat(fieldKey, "/option/").concat(optionId)
1291 }), {
1292 method: 'DELETE',
1293 followAllRedirects: true
1294 }));
1295 }
1296 /**
1297 * @name getIssueProperty
1298 * @function
1299 * Get Property of Issue by Issue and Property Id
1300 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/properties-getProperty)
1301 * @param {string} issueNumber - The issue number to search for including the project key
1302 * @param {string} property - The property key to search for
1303 */
1304
1305 }, {
1306 key: "getIssueProperty",
1307 value: function getIssueProperty(issueNumber, property) {
1308 return this.doRequest(this.makeRequestHeader(this.makeUri({
1309 pathname: "/issue/".concat(issueNumber, "/properties/").concat(property)
1310 })));
1311 }
1312 /**
1313 * @name getIssueChangelog
1314 * @function
1315 * List all changes for an issue, sorted by date, starting from the latest
1316 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/changelog)
1317 * @param {string} issueNumber - The issue number to search for including the project key
1318 * @param {integer} [startAt=0] - optional starting index number
1319 * @param {integer} [maxResults=50] - optional ending index number
1320 */
1321
1322 }, {
1323 key: "getIssueChangelog",
1324 value: function getIssueChangelog(issueNumber) {
1325 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1326 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
1327 return this.doRequest(this.makeRequestHeader(this.makeUri({
1328 pathname: "/issue/".concat(issueNumber, "/changelog"),
1329 query: {
1330 startAt: startAt,
1331 maxResults: maxResults
1332 }
1333 })));
1334 }
1335 /**
1336 * @name getIssueWatchers
1337 * @function
1338 * List all watchers for an issue
1339 * [Jira Doc](http://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getIssueWatchers)
1340 * @param {string} issueNumber - The issue number to search for including the project key
1341 */
1342
1343 }, {
1344 key: "getIssueWatchers",
1345 value: function getIssueWatchers(issueNumber) {
1346 return this.doRequest(this.makeRequestHeader(this.makeUri({
1347 pathname: "/issue/".concat(issueNumber, "/watchers")
1348 })));
1349 }
1350 /** List all priorities jira knows about
1351 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
1352 * @name listPriorities
1353 * @function
1354 */
1355
1356 }, {
1357 key: "listPriorities",
1358 value: function listPriorities() {
1359 return this.doRequest(this.makeRequestHeader(this.makeUri({
1360 pathname: '/priority'
1361 })));
1362 }
1363 /** List Transitions for a specific issue that are available to the current user
1364 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
1365 * @name listTransitions
1366 * @function
1367 * @param {string} issueId - get transitions available for the issue
1368 */
1369
1370 }, {
1371 key: "listTransitions",
1372 value: function listTransitions(issueId) {
1373 return this.doRequest(this.makeRequestHeader(this.makeUri({
1374 pathname: "/issue/".concat(issueId, "/transitions"),
1375 query: {
1376 expand: 'transitions.fields'
1377 }
1378 })));
1379 }
1380 /** Transition issue in Jira
1381 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
1382 * @name transitionsIssue
1383 * @function
1384 * @param {string} issueId - the Id of the issue to delete
1385 * @param {object} issueTransition - transition object from the jira rest API
1386 */
1387
1388 }, {
1389 key: "transitionIssue",
1390 value: function transitionIssue(issueId, issueTransition) {
1391 return this.doRequest(this.makeRequestHeader(this.makeUri({
1392 pathname: "/issue/".concat(issueId, "/transitions")
1393 }), {
1394 body: issueTransition,
1395 method: 'POST',
1396 followAllRedirects: true
1397 }));
1398 }
1399 /** List all Viewable Projects
1400 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id289193)
1401 * @name listProjects
1402 * @function
1403 */
1404
1405 }, {
1406 key: "listProjects",
1407 value: function listProjects() {
1408 return this.doRequest(this.makeRequestHeader(this.makeUri({
1409 pathname: '/project'
1410 })));
1411 }
1412 /** Add a comment to an issue
1413 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#id108798)
1414 * @name addComment
1415 * @function
1416 * @param {string} issueId - Issue to add a comment to
1417 * @param {string} comment - string containing comment
1418 */
1419
1420 }, {
1421 key: "addComment",
1422 value: function addComment(issueId, comment) {
1423 return this.doRequest(this.makeRequestHeader(this.makeUri({
1424 pathname: "/issue/".concat(issueId, "/comment")
1425 }), {
1426 body: {
1427 body: comment
1428 },
1429 method: 'POST',
1430 followAllRedirects: true
1431 }));
1432 }
1433 /** Add a comment to an issue, supports full comment object
1434 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#id108798)
1435 * @name addCommentAdvanced
1436 * @function
1437 * @param {string} issueId - Issue to add a comment to
1438 * @param {object} comment - The object containing your comment data
1439 */
1440
1441 }, {
1442 key: "addCommentAdvanced",
1443 value: function addCommentAdvanced(issueId, comment) {
1444 return this.doRequest(this.makeRequestHeader(this.makeUri({
1445 pathname: "/issue/".concat(issueId, "/comment")
1446 }), {
1447 body: comment,
1448 method: 'POST',
1449 followAllRedirects: true
1450 }));
1451 }
1452 /** Update comment for an issue
1453 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-updateComment)
1454 * @name updateComment
1455 * @function
1456 * @param {string} issueId - Issue with the comment
1457 * @param {string} commentId - Comment that is updated
1458 * @param {string} comment - string containing new comment
1459 * @param {object} [options={}] - extra options
1460 */
1461
1462 }, {
1463 key: "updateComment",
1464 value: function updateComment(issueId, commentId, comment) {
1465 var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1466 return this.doRequest(this.makeRequestHeader(this.makeUri({
1467 pathname: "/issue/".concat(issueId, "/comment/").concat(commentId)
1468 }), {
1469 body: _objectSpread({
1470 body: comment
1471 }, options),
1472 method: 'PUT',
1473 followAllRedirects: true
1474 }));
1475 }
1476 /**
1477 * @name getComments
1478 * @function
1479 * Get Comments by IssueId.
1480 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)
1481 * @param {string} issueId - this issue this comment is on
1482 */
1483
1484 }, {
1485 key: "getComments",
1486 value: function getComments(issueId) {
1487 return this.doRequest(this.makeRequestHeader(this.makeUri({
1488 pathname: "/issue/".concat(issueId, "/comment")
1489 })));
1490 }
1491 /**
1492 * @name getComment
1493 * @function
1494 * Get Comment by Id.
1495 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)
1496 * @param {string} issueId - this issue this comment is on
1497 * @param {number} commentId - the id of the comment
1498 */
1499
1500 }, {
1501 key: "getComment",
1502 value: function getComment(issueId, commentId) {
1503 return this.doRequest(this.makeRequestHeader(this.makeUri({
1504 pathname: "/issue/".concat(issueId, "/comment/").concat(commentId)
1505 })));
1506 }
1507 /**
1508 * @name deleteComment
1509 * @function
1510 * Delete Comments by Id.
1511 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)
1512 * @param {string} issueId - this issue this comment is on
1513 * @param {number} commentId - the id of the comment
1514 */
1515
1516 }, {
1517 key: "deleteComment",
1518 value: function deleteComment(issueId, commentId) {
1519 return this.doRequest(this.makeRequestHeader(this.makeUri({
1520 pathname: "/issue/".concat(issueId, "/comment/").concat(commentId)
1521 }), {
1522 method: 'DELETE',
1523 followAllRedirects: true
1524 }));
1525 }
1526 /** Add a worklog to a project
1527 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id291617)
1528 * @name addWorklog
1529 * @function
1530 * @param {string} issueId - Issue to add a worklog to
1531 * @param {object} worklog - worklog object from the rest API
1532 * @param {object} newEstimate - the new value for the remaining estimate field
1533 * @param {object} [options={}] - extra options
1534 */
1535
1536 }, {
1537 key: "addWorklog",
1538 value: function addWorklog(issueId, worklog) {
1539 var newEstimate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1540 var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1541
1542 var query = _objectSpread(_objectSpread({
1543 adjustEstimate: newEstimate ? 'new' : 'auto'
1544 }, newEstimate ? {
1545 newEstimate: newEstimate
1546 } : {}), options);
1547
1548 var header = {
1549 uri: this.makeUri({
1550 pathname: "/issue/".concat(issueId, "/worklog"),
1551 query: query
1552 }),
1553 body: worklog,
1554 method: 'POST',
1555 'Content-Type': 'application/json',
1556 json: true
1557 };
1558 return this.doRequest(header);
1559 }
1560 /** Get ids of worklogs modified since
1561 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/worklog-getWorklogsForIds)
1562 * @name updatedWorklogs
1563 * @function
1564 * @param {number} since - a date time in unix timestamp format since when updated worklogs
1565 * will be returned.
1566 * @param {string} expand - ptional comma separated list of parameters to expand: properties
1567 * (provides worklog properties).
1568 */
1569
1570 }, {
1571 key: "updatedWorklogs",
1572 value: function updatedWorklogs(since, expand) {
1573 var header = {
1574 uri: this.makeUri({
1575 pathname: '/worklog/updated',
1576 query: {
1577 since: since,
1578 expand: expand
1579 }
1580 }),
1581 method: 'GET',
1582 'Content-Type': 'application/json',
1583 json: true
1584 };
1585 return this.doRequest(header);
1586 }
1587 /** Delete worklog from issue
1588 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#d2e1673)
1589 * @name deleteWorklog
1590 * @function
1591 * @param {string} issueId - the Id of the issue to delete
1592 * @param {string} worklogId - the Id of the worklog in issue to delete
1593 */
1594
1595 }, {
1596 key: "deleteWorklog",
1597 value: function deleteWorklog(issueId, worklogId) {
1598 return this.doRequest(this.makeRequestHeader(this.makeUri({
1599 pathname: "/issue/".concat(issueId, "/worklog/").concat(worklogId)
1600 }), {
1601 method: 'DELETE',
1602 followAllRedirects: true
1603 }));
1604 }
1605 /** Deletes an issue link.
1606 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issueLink-linkId-delete)
1607 * @name deleteIssueLink
1608 * @function
1609 * @param {string} linkId - the Id of the issue link to delete
1610 */
1611
1612 }, {
1613 key: "deleteIssueLink",
1614 value: function deleteIssueLink(linkId) {
1615 return this.doRequest(this.makeRequestHeader(this.makeUri({
1616 pathname: "/issueLink/".concat(linkId)
1617 }), {
1618 method: 'DELETE',
1619 followAllRedirects: true
1620 }));
1621 }
1622 /** Returns worklog details for a list of worklog IDs.
1623 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-worklog-list-post)
1624 * @name getWorklogs
1625 * @function
1626 * @param {array} worklogsIDs - a list of worklog IDs.
1627 * @param {string} expand - expand to include additional information about worklogs
1628 *
1629 */
1630
1631 }, {
1632 key: "getWorklogs",
1633 value: function getWorklogs(worklogsIDs, expand) {
1634 return this.doRequest(this.makeRequestHeader(this.makeUri({
1635 pathname: '/worklog/list',
1636 query: {
1637 expand: expand
1638 }
1639 }), {
1640 method: 'POST',
1641 body: {
1642 ids: worklogsIDs
1643 }
1644 }));
1645 }
1646 /** Get worklogs list from a given issue
1647 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-issue-issueIdOrKey-worklog-get)
1648 * @name getIssueWorklogs
1649 * @function
1650 * @param {string} issueId - the Id of the issue to find worklogs for
1651 * @param {integer} [startAt=0] - optional starting index number
1652 * @param {integer} [maxResults=1000] - optional ending index number
1653 */
1654
1655 }, {
1656 key: "getIssueWorklogs",
1657 value: function getIssueWorklogs(issueId) {
1658 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1659 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
1660 return this.doRequest(this.makeRequestHeader(this.makeUri({
1661 pathname: "/issue/".concat(issueId, "/worklog"),
1662 query: {
1663 startAt: startAt,
1664 maxResults: maxResults
1665 }
1666 })));
1667 }
1668 /** List all Issue Types jira knows about
1669 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id295946)
1670 * @name listIssueTypes
1671 * @function
1672 */
1673
1674 }, {
1675 key: "listIssueTypes",
1676 value: function listIssueTypes() {
1677 return this.doRequest(this.makeRequestHeader(this.makeUri({
1678 pathname: '/issuetype'
1679 })));
1680 }
1681 /** Register a webhook
1682 * [Jira Doc](https://developer.atlassian.com/display/JIRADEV/JIRA+Webhooks+Overview)
1683 * @name registerWebhook
1684 * @function
1685 * @param {object} webhook - properly formatted webhook
1686 */
1687
1688 }, {
1689 key: "registerWebhook",
1690 value: function registerWebhook(webhook) {
1691 return this.doRequest(this.makeRequestHeader(this.makeWebhookUri({
1692 pathname: '/webhook'
1693 }), {
1694 method: 'POST',
1695 body: webhook
1696 }));
1697 }
1698 /** List all registered webhooks
1699 * [Jira Doc](https://developer.atlassian.com/display/JIRADEV/JIRA+Webhooks+Overview)
1700 * @name listWebhooks
1701 * @function
1702 */
1703
1704 }, {
1705 key: "listWebhooks",
1706 value: function listWebhooks() {
1707 return this.doRequest(this.makeRequestHeader(this.makeWebhookUri({
1708 pathname: '/webhook'
1709 })));
1710 }
1711 /** Get a webhook by its ID
1712 * [Jira Doc](https://developer.atlassian.com/display/JIRADEV/JIRA+Webhooks+Overview)
1713 * @name getWebhook
1714 * @function
1715 * @param {string} webhookID - id of webhook to get
1716 */
1717
1718 }, {
1719 key: "getWebhook",
1720 value: function getWebhook(webhookID) {
1721 return this.doRequest(this.makeRequestHeader(this.makeWebhookUri({
1722 pathname: "/webhook/".concat(webhookID)
1723 })));
1724 }
1725 /** Delete a registered webhook
1726 * [Jira Doc](https://developer.atlassian.com/display/JIRADEV/JIRA+Webhooks+Overview)
1727 * @name issueLink
1728 * @function
1729 * @param {string} webhookID - id of the webhook to delete
1730 */
1731
1732 }, {
1733 key: "deleteWebhook",
1734 value: function deleteWebhook(webhookID) {
1735 return this.doRequest(this.makeRequestHeader(this.makeWebhookUri({
1736 pathname: "/webhook/".concat(webhookID)
1737 }), {
1738 method: 'DELETE'
1739 }));
1740 }
1741 /** Describe the currently authenticated user
1742 * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id2e865)
1743 * @name getCurrentUser
1744 * @function
1745 */
1746
1747 }, {
1748 key: "getCurrentUser",
1749 value: function getCurrentUser() {
1750 return this.doRequest(this.makeRequestHeader(this.makeUri({
1751 pathname: '/myself'
1752 })));
1753 }
1754 /** Retrieve the backlog of a certain Rapid View
1755 * @name getBacklogForRapidView
1756 * @function
1757 * @param {string} rapidViewId - rapid view id
1758 */
1759
1760 }, {
1761 key: "getBacklogForRapidView",
1762 value: function getBacklogForRapidView(rapidViewId) {
1763 return this.doRequest(this.makeRequestHeader(this.makeUri({
1764 pathname: '/xboard/plan/backlog/data',
1765 query: {
1766 rapidViewId: rapidViewId
1767 }
1768 })));
1769 }
1770 /** Add attachment to a Issue
1771 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#api/2/issue/{issueIdOrKey}/attachments-addAttachment)
1772 * @name addAttachmentOnIssue
1773 * @function
1774 * @param {string} issueId - issue id
1775 * @param {object} readStream - readStream object from fs
1776 */
1777
1778 }, {
1779 key: "addAttachmentOnIssue",
1780 value: function addAttachmentOnIssue(issueId, readStream) {
1781 return this.doRequest(this.makeRequestHeader(this.makeUri({
1782 pathname: "/issue/".concat(issueId, "/attachments")
1783 }), {
1784 method: 'POST',
1785 headers: {
1786 'X-Atlassian-Token': 'nocheck'
1787 },
1788 formData: {
1789 file: readStream
1790 }
1791 }));
1792 }
1793 /** Notify people related to issue
1794 * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-notify)
1795 * @name issueNotify
1796 * @function
1797 * @param {string} issueId - issue id
1798 * @param {object} notificationBody - properly formatted body
1799 */
1800
1801 }, {
1802 key: "issueNotify",
1803 value: function issueNotify(issueId, notificationBody) {
1804 return this.doRequest(this.makeRequestHeader(this.makeUri({
1805 pathname: "/issue/".concat(issueId, "/notify")
1806 }), {
1807 method: 'POST',
1808 body: notificationBody
1809 }));
1810 }
1811 /** Get list of possible statuses
1812 * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#api/2/status-getStatuses)
1813 * @name listStatus
1814 * @function
1815 */
1816
1817 }, {
1818 key: "listStatus",
1819 value: function listStatus() {
1820 return this.doRequest(this.makeRequestHeader(this.makeUri({
1821 pathname: '/status'
1822 })));
1823 }
1824 /** Get a Dev-Status summary by issue ID
1825 * @name getDevStatusSummary
1826 * @function
1827 * @param {string} issueId - id of issue to get
1828 */
1829
1830 }, {
1831 key: "getDevStatusSummary",
1832 value: function getDevStatusSummary(issueId) {
1833 return this.doRequest(this.makeRequestHeader(this.makeDevStatusUri({
1834 pathname: '/summary',
1835 query: {
1836 issueId: issueId
1837 }
1838 })));
1839 }
1840 /** Get a Dev-Status detail by issue ID
1841 * @name getDevStatusDetail
1842 * @function
1843 * @param {string} issueId - id of issue to get
1844 * @param {string} applicationType - type of application (stash, bitbucket)
1845 * @param {string} dataType - info to return (repository, pullrequest)
1846 */
1847
1848 }, {
1849 key: "getDevStatusDetail",
1850 value: function getDevStatusDetail(issueId, applicationType, dataType) {
1851 return this.doRequest(this.makeRequestHeader(this.makeDevStatusUri({
1852 pathname: '/detail',
1853 query: {
1854 issueId: issueId,
1855 applicationType: applicationType,
1856 dataType: dataType
1857 }
1858 })));
1859 }
1860 /** Get issue
1861 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/issue-getIssue)
1862 * @name getIssue
1863 * @function
1864 * @param {string} issueIdOrKey - Id of issue
1865 * @param {string} [fields] - The list of fields to return for each issue.
1866 * @param {string} [expand] - A comma-separated list of the parameters to expand.
1867 */
1868
1869 }, {
1870 key: "getIssue",
1871 value: function getIssue(issueIdOrKey, fields, expand) {
1872 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
1873 pathname: "/issue/".concat(issueIdOrKey),
1874 query: {
1875 fields: fields,
1876 expand: expand
1877 }
1878 })));
1879 }
1880 /** Move issues to backlog
1881 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/backlog-moveIssuesToBacklog)
1882 * @name moveToBacklog
1883 * @function
1884 * @param {array} issues - id or key of issues to get
1885 */
1886
1887 }, {
1888 key: "moveToBacklog",
1889 value: function moveToBacklog(issues) {
1890 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
1891 pathname: '/backlog/issue'
1892 }), {
1893 method: 'POST',
1894 body: {
1895 issues: issues
1896 }
1897 }));
1898 }
1899 /** Get all boards
1900 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getAllBoards)
1901 * @name getAllBoards
1902 * @function
1903 * @param {number} [startAt=0] - The starting index of the returned boards.
1904 * @param {number} [maxResults=50] - The maximum number of boards to return per page.
1905 * @param {string} [type] - Filters results to boards of the specified type.
1906 * @param {string} [name] - Filters results to boards that match the specified name.
1907 * @param {string} [projectKeyOrId] - Filters results to boards that are relevant to a project.
1908 */
1909
1910 }, {
1911 key: "getAllBoards",
1912 value: function getAllBoards() {
1913 var startAt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1914 var maxResults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
1915 var type = arguments.length > 2 ? arguments[2] : undefined;
1916 var name = arguments.length > 3 ? arguments[3] : undefined;
1917 var projectKeyOrId = arguments.length > 4 ? arguments[4] : undefined;
1918 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
1919 pathname: '/board',
1920 query: _objectSpread({
1921 startAt: startAt,
1922 maxResults: maxResults,
1923 type: type,
1924 name: name
1925 }, projectKeyOrId && {
1926 projectKeyOrId: projectKeyOrId
1927 })
1928 })));
1929 }
1930 /** Create Board
1931 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-createBoard)
1932 * @name createBoard
1933 * @function
1934 * @param {object} boardBody - Board name, type and filter Id is required.
1935 * @param {string} boardBody.type - Valid values: scrum, kanban
1936 * @param {string} boardBody.name - Must be less than 255 characters.
1937 * @param {string} boardBody.filterId - Id of a filter that the user has permissions to view.
1938 */
1939
1940 }, {
1941 key: "createBoard",
1942 value: function createBoard(boardBody) {
1943 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
1944 pathname: '/board'
1945 }), {
1946 method: 'POST',
1947 body: boardBody
1948 }));
1949 }
1950 /** Get Board
1951 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getBoard)
1952 * @name getBoard
1953 * @function
1954 * @param {string} boardId - Id of board to retrieve
1955 */
1956
1957 }, {
1958 key: "getBoard",
1959 value: function getBoard(boardId) {
1960 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
1961 pathname: "/board/".concat(boardId)
1962 })));
1963 }
1964 /** Delete Board
1965 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-deleteBoard)
1966 * @name deleteBoard
1967 * @function
1968 * @param {string} boardId - Id of board to retrieve
1969 */
1970
1971 }, {
1972 key: "deleteBoard",
1973 value: function deleteBoard(boardId) {
1974 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
1975 pathname: "/board/".concat(boardId)
1976 }), {
1977 method: 'DELETE'
1978 }));
1979 }
1980 /** Get issues for backlog
1981 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getIssuesForBacklog)
1982 * @name getIssuesForBacklog
1983 * @function
1984 * @param {string} boardId - Id of board to retrieve
1985 * @param {number} [startAt=0] - The starting index of the returned issues. Base index: 0.
1986 * @param {number} [maxResults=50] - The maximum number of issues to return per page. Default: 50.
1987 * @param {string} [jql] - Filters results using a JQL query.
1988 * @param {boolean} [validateQuery] - Specifies whether to validate the JQL query or not.
1989 * Default: true.
1990 * @param {string} [fields] - The list of fields to return for each issue.
1991 */
1992
1993 }, {
1994 key: "getIssuesForBacklog",
1995 value: function getIssuesForBacklog(boardId) {
1996 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1997 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
1998 var jql = arguments.length > 3 ? arguments[3] : undefined;
1999 var validateQuery = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
2000 var fields = arguments.length > 5 ? arguments[5] : undefined;
2001 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2002 pathname: "/board/".concat(boardId, "/backlog"),
2003 query: {
2004 startAt: startAt,
2005 maxResults: maxResults,
2006 jql: jql,
2007 validateQuery: validateQuery,
2008 fields: fields
2009 }
2010 })));
2011 }
2012 /** Get Configuration
2013 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getConfiguration)
2014 * @name getConfiguration
2015 * @function
2016 * @param {string} boardId - Id of board to retrieve
2017 */
2018
2019 }, {
2020 key: "getConfiguration",
2021 value: function getConfiguration(boardId) {
2022 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2023 pathname: "/board/".concat(boardId, "/configuration")
2024 })));
2025 }
2026 /** Get issues for board
2027 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getIssuesForBoard)
2028 * @name getIssuesForBoard
2029 * @function
2030 * @param {string} boardId - Id of board to retrieve
2031 * @param {number} [startAt=0] - The starting index of the returned issues. Base index: 0.
2032 * @param {number} [maxResults=50] - The maximum number of issues to return per page. Default: 50.
2033 * @param {string} [jql] - Filters results using a JQL query.
2034 * @param {boolean} [validateQuery] - Specifies whether to validate the JQL query or not.
2035 * Default: true.
2036 * @param {string} [fields] - The list of fields to return for each issue.
2037 */
2038
2039 }, {
2040 key: "getIssuesForBoard",
2041 value: function getIssuesForBoard(boardId) {
2042 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2043 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
2044 var jql = arguments.length > 3 ? arguments[3] : undefined;
2045 var validateQuery = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
2046 var fields = arguments.length > 5 ? arguments[5] : undefined;
2047 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2048 pathname: "/board/".concat(boardId, "/issue"),
2049 query: {
2050 startAt: startAt,
2051 maxResults: maxResults,
2052 jql: jql,
2053 validateQuery: validateQuery,
2054 fields: fields
2055 }
2056 })));
2057 }
2058 /** Get issue estimation for board
2059 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/issue-getIssueEstimationForBoard)
2060 * @name getIssueEstimationForBoard
2061 * @function
2062 * @param {string} issueIdOrKey - Id of issue
2063 * @param {number} boardId - The id of the board required to determine which field
2064 * is used for estimation.
2065 */
2066
2067 }, {
2068 key: "getIssueEstimationForBoard",
2069 value: function getIssueEstimationForBoard(issueIdOrKey, boardId) {
2070 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2071 pathname: "/issue/".concat(issueIdOrKey, "/estimation"),
2072 query: {
2073 boardId: boardId
2074 }
2075 })));
2076 }
2077 /** Get Epics
2078 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/epic-getEpics)
2079 * @name getEpics
2080 * @function
2081 * @param {string} boardId - Id of board to retrieve
2082 * @param {number} [startAt=0] - The starting index of the returned epics. Base index: 0.
2083 * @param {number} [maxResults=50] - The maximum number of epics to return per page. Default: 50.
2084 * @param {string} [done] - Filters results to epics that are either done or not done.
2085 * Valid values: true, false.
2086 */
2087
2088 }, {
2089 key: "getEpics",
2090 value: function getEpics(boardId) {
2091 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2092 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
2093 var done = arguments.length > 3 ? arguments[3] : undefined;
2094 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2095 pathname: "/board/".concat(boardId, "/epic"),
2096 query: {
2097 startAt: startAt,
2098 maxResults: maxResults,
2099 done: done
2100 }
2101 })));
2102 }
2103 /** Get board issues for epic
2104 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/epic-getIssuesForEpic)
2105 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/epic-getIssuesWithoutEpic)
2106 * @name getBoardIssuesForEpic
2107 * @function
2108 * @param {string} boardId - Id of board to retrieve
2109 * @param {string} epicId - Id of epic to retrieve, specify 'none' to get issues without an epic.
2110 * @param {number} [startAt=0] - The starting index of the returned issues. Base index: 0.
2111 * @param {number} [maxResults=50] - The maximum number of issues to return per page. Default: 50.
2112 * @param {string} [jql] - Filters results using a JQL query.
2113 * @param {boolean} [validateQuery] - Specifies whether to validate the JQL query or not.
2114 * Default: true.
2115 * @param {string} [fields] - The list of fields to return for each issue.
2116 */
2117
2118 }, {
2119 key: "getBoardIssuesForEpic",
2120 value: function getBoardIssuesForEpic(boardId, epicId) {
2121 var startAt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2122 var maxResults = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 50;
2123 var jql = arguments.length > 4 ? arguments[4] : undefined;
2124 var validateQuery = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
2125 var fields = arguments.length > 6 ? arguments[6] : undefined;
2126 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2127 pathname: "/board/".concat(boardId, "/epic/").concat(epicId, "/issue"),
2128 query: {
2129 startAt: startAt,
2130 maxResults: maxResults,
2131 jql: jql,
2132 validateQuery: validateQuery,
2133 fields: fields
2134 }
2135 })));
2136 }
2137 /** Estimate issue for board
2138 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/issue-estimateIssueForBoard)
2139 * @name estimateIssueForBoard
2140 * @function
2141 * @param {string} issueIdOrKey - Id of issue
2142 * @param {number} boardId - The id of the board required to determine which field
2143 * is used for estimation.
2144 * @param {string} body - value to set
2145 */
2146
2147 }, {
2148 key: "estimateIssueForBoard",
2149 value: function estimateIssueForBoard(issueIdOrKey, boardId, body) {
2150 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2151 pathname: "/issue/".concat(issueIdOrKey, "/estimation"),
2152 query: {
2153 boardId: boardId
2154 }
2155 }), {
2156 method: 'PUT',
2157 body: body
2158 }));
2159 }
2160 /** Rank Issues
2161 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/issue-rankIssues)
2162 * @name rankIssues
2163 * @function
2164 * @param {string} body - value to set
2165 */
2166
2167 }, {
2168 key: "rankIssues",
2169 value: function rankIssues(body) {
2170 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2171 pathname: '/issue/rank'
2172 }), {
2173 method: 'PUT',
2174 body: body
2175 }));
2176 }
2177 /** Get Projects
2178 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/project-getProjects)
2179 * @name getProjects
2180 * @function
2181 * @param {string} boardId - Id of board to retrieve
2182 * @param {number} [startAt=0] - The starting index of the returned projects. Base index: 0.
2183 * @param {number} [maxResults=50] - The maximum number of projects to return per page.
2184 * Default: 50.
2185 */
2186
2187 }, {
2188 key: "getProjects",
2189 value: function getProjects(boardId) {
2190 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2191 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
2192 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2193 pathname: "/board/".concat(boardId, "/project"),
2194 query: {
2195 startAt: startAt,
2196 maxResults: maxResults
2197 }
2198 })));
2199 }
2200 /** Get Projects Full
2201 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/project-getProjectsFull)
2202 * @name getProjectsFull
2203 * @function
2204 * @param {string} boardId - Id of board to retrieve
2205 */
2206
2207 }, {
2208 key: "getProjectsFull",
2209 value: function getProjectsFull(boardId) {
2210 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2211 pathname: "/board/".concat(boardId, "/project/full")
2212 })));
2213 }
2214 /** Get Board Properties Keys
2215 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/properties-getPropertiesKeys)
2216 * @name getBoardPropertiesKeys
2217 * @function
2218 * @param {string} boardId - Id of board to retrieve
2219 */
2220
2221 }, {
2222 key: "getBoardPropertiesKeys",
2223 value: function getBoardPropertiesKeys(boardId) {
2224 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2225 pathname: "/board/".concat(boardId, "/properties")
2226 })));
2227 }
2228 /** Delete Board Property
2229 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/properties-deleteProperty)
2230 * @name deleteBoardProperty
2231 * @function
2232 * @param {string} boardId - Id of board to retrieve
2233 * @param {string} propertyKey - Id of property to delete
2234 */
2235
2236 }, {
2237 key: "deleteBoardProperty",
2238 value: function deleteBoardProperty(boardId, propertyKey) {
2239 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2240 pathname: "/board/".concat(boardId, "/properties/").concat(propertyKey)
2241 }), {
2242 method: 'DELETE'
2243 }));
2244 }
2245 /** Set Board Property
2246 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/properties-setProperty)
2247 * @name setBoardProperty
2248 * @function
2249 * @param {string} boardId - Id of board to retrieve
2250 * @param {string} propertyKey - Id of property to delete
2251 * @param {string} body - value to set, for objects make sure to stringify first
2252 */
2253
2254 }, {
2255 key: "setBoardProperty",
2256 value: function setBoardProperty(boardId, propertyKey, body) {
2257 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2258 pathname: "/board/".concat(boardId, "/properties/").concat(propertyKey)
2259 }), {
2260 method: 'PUT',
2261 body: body
2262 }));
2263 }
2264 /** Get Board Property
2265 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/properties-getProperty)
2266 * @name getBoardProperty
2267 * @function
2268 * @param {string} boardId - Id of board to retrieve
2269 * @param {string} propertyKey - Id of property to retrieve
2270 */
2271
2272 }, {
2273 key: "getBoardProperty",
2274 value: function getBoardProperty(boardId, propertyKey) {
2275 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2276 pathname: "/board/".concat(boardId, "/properties/").concat(propertyKey)
2277 })));
2278 }
2279 /** Get All Sprints
2280 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/sprint-getAllSprints)
2281 * @name getAllSprints
2282 * @function
2283 * @param {string} boardId - Id of board to retrieve
2284 * @param {number} [startAt=0] - The starting index of the returned sprints. Base index: 0.
2285 * @param {number} [maxResults=50] - The maximum number of sprints to return per page.
2286 * Default: 50.
2287 * @param {string} [state] - Filters results to sprints in specified states.
2288 * Valid values: future, active, closed.
2289 */
2290
2291 }, {
2292 key: "getAllSprints",
2293 value: function getAllSprints(boardId) {
2294 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2295 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
2296 var state = arguments.length > 3 ? arguments[3] : undefined;
2297 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2298 pathname: "/board/".concat(boardId, "/sprint"),
2299 query: {
2300 startAt: startAt,
2301 maxResults: maxResults,
2302 state: state
2303 }
2304 })));
2305 }
2306 /** Get Board issues for sprint
2307 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/sprint-getIssuesForSprint)
2308 * @name getBoardIssuesForSprint
2309 * @function
2310 * @param {string} boardId - Id of board to retrieve
2311 * @param {string} sprintId - Id of sprint to retrieve
2312 * @param {number} [startAt=0] - The starting index of the returned issues. Base index: 0.
2313 * @param {number} [maxResults=50] - The maximum number of issues to return per page. Default: 50.
2314 * @param {string} [jql] - Filters results using a JQL query.
2315 * @param {boolean} [validateQuery] - Specifies whether to validate the JQL query or not.
2316 * Default: true.
2317 * @param {string} [fields] - The list of fields to return for each issue.
2318 */
2319
2320 }, {
2321 key: "getBoardIssuesForSprint",
2322 value: function getBoardIssuesForSprint(boardId, sprintId) {
2323 var startAt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2324 var maxResults = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 50;
2325 var jql = arguments.length > 4 ? arguments[4] : undefined;
2326 var validateQuery = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
2327 var fields = arguments.length > 6 ? arguments[6] : undefined;
2328 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2329 pathname: "/board/".concat(boardId, "/sprint/").concat(sprintId, "/issue"),
2330 query: {
2331 startAt: startAt,
2332 maxResults: maxResults,
2333 jql: jql,
2334 validateQuery: validateQuery,
2335 fields: fields
2336 }
2337 })));
2338 }
2339 /** Get All Versions
2340 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/version-getAllVersions)
2341 * @name getAllVersions
2342 * @function
2343 * @param {string} boardId - Id of board to retrieve
2344 * @param {number} [startAt=0] - The starting index of the returned versions. Base index: 0.
2345 * @param {number} [maxResults=50] - The maximum number of versions to return per page.
2346 * Default: 50.
2347 * @param {string} [released] - Filters results to versions that are either released or
2348 * unreleased.Valid values: true, false.
2349 */
2350
2351 }, {
2352 key: "getAllVersions",
2353 value: function getAllVersions(boardId) {
2354 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2355 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
2356 var released = arguments.length > 3 ? arguments[3] : undefined;
2357 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2358 pathname: "/board/".concat(boardId, "/version"),
2359 query: {
2360 startAt: startAt,
2361 maxResults: maxResults,
2362 released: released
2363 }
2364 })));
2365 }
2366 /** Get Filter
2367 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/filter)
2368 * @name getFilter
2369 * @function
2370 * @param {string} filterId - Id of filter to retrieve
2371 */
2372
2373 }, {
2374 key: "getFilter",
2375 value: function getFilter(filterId) {
2376 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2377 pathname: "/filter/".concat(filterId)
2378 })));
2379 }
2380 /** Get Epic
2381 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-getEpic)
2382 * @name getEpic
2383 * @function
2384 * @param {string} epicIdOrKey - Id of epic to retrieve
2385 */
2386
2387 }, {
2388 key: "getEpic",
2389 value: function getEpic(epicIdOrKey) {
2390 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2391 pathname: "/epic/".concat(epicIdOrKey)
2392 })));
2393 }
2394 /** Partially update epic
2395 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-partiallyUpdateEpic)
2396 * @name partiallyUpdateEpic
2397 * @function
2398 * @param {string} epicIdOrKey - Id of epic to retrieve
2399 * @param {string} body - value to set, for objects make sure to stringify first
2400 */
2401
2402 }, {
2403 key: "partiallyUpdateEpic",
2404 value: function partiallyUpdateEpic(epicIdOrKey, body) {
2405 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2406 pathname: "/epic/".concat(epicIdOrKey)
2407 }), {
2408 method: 'POST',
2409 body: body
2410 }));
2411 }
2412 /** Get issues for epic
2413 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-getIssuesForEpic)
2414 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-getIssuesWithoutEpic)
2415 * @name getIssuesForEpic
2416 * @function
2417 * @param {string} epicId - Id of epic to retrieve, specify 'none' to get issues without an epic.
2418 * @param {number} [startAt=0] - The starting index of the returned issues. Base index: 0.
2419 * @param {number} [maxResults=50] - The maximum number of issues to return per page. Default: 50.
2420 * @param {string} [jql] - Filters results using a JQL query.
2421 * @param {boolean} [validateQuery] - Specifies whether to validate the JQL query or not.
2422 * Default: true.
2423 * @param {string} [fields] - The list of fields to return for each issue.
2424 */
2425
2426 }, {
2427 key: "getIssuesForEpic",
2428 value: function getIssuesForEpic(epicId) {
2429 var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2430 var maxResults = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
2431 var jql = arguments.length > 3 ? arguments[3] : undefined;
2432 var validateQuery = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
2433 var fields = arguments.length > 5 ? arguments[5] : undefined;
2434 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2435 pathname: "/epic/".concat(epicId, "/issue"),
2436 query: {
2437 startAt: startAt,
2438 maxResults: maxResults,
2439 jql: jql,
2440 validateQuery: validateQuery,
2441 fields: fields
2442 }
2443 })));
2444 }
2445 /** Move Issues to Epic
2446 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-moveIssuesToEpic)
2447 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-removeIssuesFromEpic)
2448 * @name moveIssuesToEpic
2449 * @function
2450 * @param {string} epicIdOrKey - Id of epic to move issue to, or 'none' to remove from epic
2451 * @param {array} issues - array of issues to move
2452 */
2453
2454 }, {
2455 key: "moveIssuesToEpic",
2456 value: function moveIssuesToEpic(epicIdOrKey, issues) {
2457 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2458 pathname: "/epic/".concat(epicIdOrKey, "/issue")
2459 }), {
2460 method: 'POST',
2461 body: {
2462 issues: issues
2463 }
2464 }));
2465 }
2466 /** Rank Epics
2467 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/epic-rankEpics)
2468 * @name rankEpics
2469 * @function
2470 * @param {string} epicIdOrKey - Id of epic
2471 * @param {string} body - value to set
2472 */
2473
2474 }, {
2475 key: "rankEpics",
2476 value: function rankEpics(epicIdOrKey, body) {
2477 return this.doRequest(this.makeRequestHeader(this.makeAgileUri({
2478 pathname: "/epic/".concat(epicIdOrKey, "/rank")
2479 }), {
2480 method: 'PUT',
2481 body: body
2482 }));
2483 }
2484 /**
2485 * @name getServerInfo
2486 * @function
2487 * Get server info
2488 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-api-2-serverInfo-get)
2489 */
2490
2491 }, {
2492 key: "getServerInfo",
2493 value: function getServerInfo() {
2494 return this.doRequest(this.makeRequestHeader(this.makeUri({
2495 pathname: '/serverInfo'
2496 })));
2497 }
2498 /**
2499 * @name getIssueCreateMetadata
2500 * @param {object} optional - object containing any of the following properties
2501 * @param {array} [optional.projectIds]: optional Array of project ids to return metadata for
2502 * @param {array} [optional.projectKeys]: optional Array of project keys to return metadata for
2503 * @param {array} [optional.issuetypeIds]: optional Array of issuetype ids to return metadata for
2504 * @param {array} [optional.issuetypeNames]: optional Array of issuetype names to return metadata
2505 * for
2506 * @param {string} [optional.expand]: optional Include additional information about issue
2507 * metadata. Valid value is 'projects.issuetypes.fields'
2508 * Get metadata for creating an issue.
2509 * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-get)
2510 */
2511
2512 }, {
2513 key: "getIssueCreateMetadata",
2514 value: function getIssueCreateMetadata() {
2515 var optional = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2516 return this.doRequest(this.makeRequestHeader(this.makeUri({
2517 pathname: '/issue/createmeta',
2518 query: optional
2519 })));
2520 }
2521 /** Generic Get Request
2522 * [Jira Doc](https://docs.atlassian.com/jira-software/REST/cloud/2/)
2523 * @name genericGet
2524 * @function
2525 * @param {string} endpoint - Rest API endpoint
2526 */
2527
2528 }, {
2529 key: "genericGet",
2530 value: function genericGet(endpoint) {
2531 return this.doRequest(this.makeRequestHeader(this.makeUri({
2532 pathname: "/".concat(endpoint)
2533 })));
2534 }
2535 }]);
2536 return JiraApi;
2537}();
2538
2539exports["default"] = JiraApi;
2540module.exports = exports.default;
\No newline at end of file