diff --git a/dist/backlog.js b/dist/backlog.js index 7c3cae1..19441b9 100644 --- a/dist/backlog.js +++ b/dist/backlog.js @@ -1,15 +1,21 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Backlog = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0 ? "?" + qs : ''); + var url = this.restBaseURL + "/" + path + (qs.length > 0 ? "?" + qs : ''); return fetch(url, init).then(this.checkStatus); }; Request.prototype.checkStatus = function (response) { @@ -719,7 +735,6 @@ var Request = (function () { }); return Request; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Request; },{"./error":3}]},{},[4])(4) diff --git a/dist/backlog.min.js b/dist/backlog.min.js index 95628f5..5cf721f 100644 --- a/dist/backlog.min.js +++ b/dist/backlog.min.js @@ -1 +1 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Backlog=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i0}).join("&")};OAuth2.prototype.getAccessToken=function(options){return new request_1.default({host:options.host,timeout:this.timeout}).post("oauth2/token",{grant_type:"authorization_code",code:options.code,client_id:this.credentials.clientId,client_secret:this.credentials.clientSecret,redirect_uri:options.redirectUri})};OAuth2.prototype.refreshAccessToken=function(options){return new request_1.default({host:options.host,timeout:this.timeout}).post("oauth2/token",{grant_type:"refresh_token",client_id:this.credentials.clientId,client_secret:this.credentials.clientSecret,refresh_token:options.refreshToken})};return OAuth2}();Object.defineProperty(exports,"__esModule",{value:true});exports.default=OAuth2},{"./request":7}],6:[function(require,module,exports){"use strict";(function(ActivityType){ActivityType[ActivityType["Undefined"]=-1]="Undefined";ActivityType[ActivityType["IssueCreated"]=1]="IssueCreated";ActivityType[ActivityType["IssueUpdated"]=2]="IssueUpdated";ActivityType[ActivityType["IssueCommented"]=3]="IssueCommented";ActivityType[ActivityType["IssueDeleted"]=4]="IssueDeleted";ActivityType[ActivityType["WikiCreated"]=5]="WikiCreated";ActivityType[ActivityType["WikiUpdated"]=6]="WikiUpdated";ActivityType[ActivityType["WikiDeleted"]=7]="WikiDeleted";ActivityType[ActivityType["FileAdded"]=8]="FileAdded";ActivityType[ActivityType["FileUpdated"]=9]="FileUpdated";ActivityType[ActivityType["FileDeleted"]=10]="FileDeleted";ActivityType[ActivityType["SvnCommitted"]=11]="SvnCommitted";ActivityType[ActivityType["GitPushed"]=12]="GitPushed";ActivityType[ActivityType["GitRepositoryCreated"]=13]="GitRepositoryCreated";ActivityType[ActivityType["IssueMultiUpdated"]=14]="IssueMultiUpdated";ActivityType[ActivityType["ProjectUserAdded"]=15]="ProjectUserAdded";ActivityType[ActivityType["ProjectUserRemoved"]=16]="ProjectUserRemoved";ActivityType[ActivityType["NotifyAdded"]=17]="NotifyAdded";ActivityType[ActivityType["PullRequestAdded"]=18]="PullRequestAdded";ActivityType[ActivityType["PullRequestUpdated"]=19]="PullRequestUpdated";ActivityType[ActivityType["PullRequestCommented"]=20]="PullRequestCommented";ActivityType[ActivityType["PullRequestMerged"]=21]="PullRequestMerged"})(exports.ActivityType||(exports.ActivityType={}));var ActivityType=exports.ActivityType;var User;(function(User){(function(RoleType){RoleType[RoleType["Admin"]=1]="Admin";RoleType[RoleType["User"]=2]="User";RoleType[RoleType["Reporter"]=3]="Reporter";RoleType[RoleType["Viewer"]=4]="Viewer";RoleType[RoleType["GuestReporter"]=5]="GuestReporter";RoleType[RoleType["GuestViewer"]=6]="GuestViewer"})(User.RoleType||(User.RoleType={}));var RoleType=User.RoleType})(User=exports.User||(exports.User={}));var Project;(function(Project){(function(FieldType){FieldType[FieldType["Text"]=1]="Text";FieldType[FieldType["TextArea"]=2]="TextArea";FieldType[FieldType["Numeric"]=3]="Numeric";FieldType[FieldType["Date"]=4]="Date";FieldType[FieldType["SingleList"]=5]="SingleList";FieldType[FieldType["MultipleList"]=6]="MultipleList";FieldType[FieldType["CheckBox"]=7]="CheckBox";FieldType[FieldType["Radio"]=8]="Radio"})(Project.FieldType||(Project.FieldType={}));var FieldType=Project.FieldType})(Project=exports.Project||(exports.Project={}));var Issue;(function(Issue){(function(ParentChildType){ParentChildType[ParentChildType["All"]=0]="All";ParentChildType[ParentChildType["NotChild"]=1]="NotChild";ParentChildType[ParentChildType["Child"]=2]="Child";ParentChildType[ParentChildType["NotChildNotParent"]=3]="NotChildNotParent";ParentChildType[ParentChildType["Parent"]=4]="Parent"})(Issue.ParentChildType||(Issue.ParentChildType={}));var ParentChildType=Issue.ParentChildType})(Issue=exports.Issue||(exports.Issue={}))},{}],7:[function(require,module,exports){"use strict";var Error=require("./error");var Request=function(){function Request(configure){this.configure=configure}Request.prototype.get=function(path,params){return this.request({method:"GET",path:path,params:params}).then(this.parseJSON)};Request.prototype.post=function(path,params){return this.request({method:"POST",path:path,params:params}).then(this.parseJSON)};Request.prototype.put=function(path,params){return this.request({method:"PUT",path:path,params:params}).then(this.parseJSON)};Request.prototype.patch=function(path,params){return this.request({method:"PATCH",path:path,params:params}).then(this.parseJSON)};Request.prototype.delete=function(path,params){return this.request({method:"DELETE",path:path,params:params}).then(this.parseJSON)};Request.prototype.request=function(options){var method=options.method,path=options.path,_a=options.params,params=_a===void 0?{}:_a;var _b=this.configure,apiKey=_b.apiKey,accessToken=_b.accessToken,timeout=_b.timeout;var query=apiKey?{apiKey:apiKey}:{};var init={method:method,headers:{}};if(timeout){init["timeout"]=timeout}if(!apiKey&&accessToken){init.headers["Authorization"]="Bearer "+accessToken}if(typeof window!=="undefined"){init.mode="cors"}if(method!=="GET"){if(params instanceof FormData){init.body=params}else{init.headers["Content-type"]="application/x-www-form-urlencoded";init.body=this.toQueryString(params)}}else{Object.keys(params).forEach(function(key){return query[key]=params[key]})}var qs=this.toQueryString(query);var url=this.restBaseURL+"/"+path+(qs.length>0?"?"+qs:"");return fetch(url,init).then(this.checkStatus)};Request.prototype.checkStatus=function(response){return new Promise(function(resolve,reject){if(200<=response.status&&response.status<300){resolve(response)}else{response.json().then(function(data){if(response.status===401){reject(new Error.BacklogAuthError(response,data))}else{reject(new Error.BacklogApiError(response,data))}}).catch(function(err){return reject(new Error.UnexpectedError(response))})}})};Request.prototype.parseJSON=function(response){return response.json()};Request.prototype.toQueryString=function(params){return Object.keys(params).reduce(function(result,key){var value=params[key];if(!value){return result}if(Array.isArray(value)){value.forEach(function(v){return result.push(key+"[]="+v)})}else{result.push(key+"="+value)}return result},[]).join("&")};Object.defineProperty(Request.prototype,"webAppBaseURL",{get:function(){return"https://"+this.configure.host},enumerable:true,configurable:true});Object.defineProperty(Request.prototype,"restBaseURL",{get:function(){return this.webAppBaseURL+"/api/v2"},enumerable:true,configurable:true});return Request}();Object.defineProperty(exports,"__esModule",{value:true});exports.default=Request},{"./error":3}]},{},[4])(4)}); \ No newline at end of file +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Backlog=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i0}).join("&")};OAuth2.prototype.getAccessToken=function(options){return new request_1.default({host:options.host,timeout:this.timeout}).post("oauth2/token",{grant_type:"authorization_code",code:options.code,client_id:this.credentials.clientId,client_secret:this.credentials.clientSecret,redirect_uri:options.redirectUri})};OAuth2.prototype.refreshAccessToken=function(options){return new request_1.default({host:options.host,timeout:this.timeout}).post("oauth2/token",{grant_type:"refresh_token",client_id:this.credentials.clientId,client_secret:this.credentials.clientSecret,refresh_token:options.refreshToken})};return OAuth2}();exports.default=OAuth2},{"./request":7}],6:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ActivityType;(function(ActivityType){ActivityType[ActivityType["Undefined"]=-1]="Undefined";ActivityType[ActivityType["IssueCreated"]=1]="IssueCreated";ActivityType[ActivityType["IssueUpdated"]=2]="IssueUpdated";ActivityType[ActivityType["IssueCommented"]=3]="IssueCommented";ActivityType[ActivityType["IssueDeleted"]=4]="IssueDeleted";ActivityType[ActivityType["WikiCreated"]=5]="WikiCreated";ActivityType[ActivityType["WikiUpdated"]=6]="WikiUpdated";ActivityType[ActivityType["WikiDeleted"]=7]="WikiDeleted";ActivityType[ActivityType["FileAdded"]=8]="FileAdded";ActivityType[ActivityType["FileUpdated"]=9]="FileUpdated";ActivityType[ActivityType["FileDeleted"]=10]="FileDeleted";ActivityType[ActivityType["SvnCommitted"]=11]="SvnCommitted";ActivityType[ActivityType["GitPushed"]=12]="GitPushed";ActivityType[ActivityType["GitRepositoryCreated"]=13]="GitRepositoryCreated";ActivityType[ActivityType["IssueMultiUpdated"]=14]="IssueMultiUpdated";ActivityType[ActivityType["ProjectUserAdded"]=15]="ProjectUserAdded";ActivityType[ActivityType["ProjectUserRemoved"]=16]="ProjectUserRemoved";ActivityType[ActivityType["NotifyAdded"]=17]="NotifyAdded";ActivityType[ActivityType["PullRequestAdded"]=18]="PullRequestAdded";ActivityType[ActivityType["PullRequestUpdated"]=19]="PullRequestUpdated";ActivityType[ActivityType["PullRequestCommented"]=20]="PullRequestCommented";ActivityType[ActivityType["PullRequestMerged"]=21]="PullRequestMerged"})(ActivityType=exports.ActivityType||(exports.ActivityType={}));var User;(function(User){var RoleType;(function(RoleType){RoleType[RoleType["Admin"]=1]="Admin";RoleType[RoleType["User"]=2]="User";RoleType[RoleType["Reporter"]=3]="Reporter";RoleType[RoleType["Viewer"]=4]="Viewer";RoleType[RoleType["GuestReporter"]=5]="GuestReporter";RoleType[RoleType["GuestViewer"]=6]="GuestViewer"})(RoleType=User.RoleType||(User.RoleType={}))})(User=exports.User||(exports.User={}));var Project;(function(Project){var FieldType;(function(FieldType){FieldType[FieldType["Text"]=1]="Text";FieldType[FieldType["TextArea"]=2]="TextArea";FieldType[FieldType["Numeric"]=3]="Numeric";FieldType[FieldType["Date"]=4]="Date";FieldType[FieldType["SingleList"]=5]="SingleList";FieldType[FieldType["MultipleList"]=6]="MultipleList";FieldType[FieldType["CheckBox"]=7]="CheckBox";FieldType[FieldType["Radio"]=8]="Radio"})(FieldType=Project.FieldType||(Project.FieldType={}))})(Project=exports.Project||(exports.Project={}));var Issue;(function(Issue){var ParentChildType;(function(ParentChildType){ParentChildType[ParentChildType["All"]=0]="All";ParentChildType[ParentChildType["NotChild"]=1]="NotChild";ParentChildType[ParentChildType["Child"]=2]="Child";ParentChildType[ParentChildType["NotChildNotParent"]=3]="NotChildNotParent";ParentChildType[ParentChildType["Parent"]=4]="Parent"})(ParentChildType=Issue.ParentChildType||(Issue.ParentChildType={}))})(Issue=exports.Issue||(exports.Issue={}))},{}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Error=require("./error");var Request=function(){function Request(configure){this.configure=configure}Request.prototype.get=function(path,params){return this.request({method:"GET",path:path,params:params}).then(this.parseJSON)};Request.prototype.post=function(path,params){return this.request({method:"POST",path:path,params:params}).then(this.parseJSON)};Request.prototype.put=function(path,params){return this.request({method:"PUT",path:path,params:params}).then(this.parseJSON)};Request.prototype.patch=function(path,params){return this.request({method:"PATCH",path:path,params:params}).then(this.parseJSON)};Request.prototype.delete=function(path,params){return this.request({method:"DELETE",path:path,params:params}).then(this.parseJSON)};Request.prototype.request=function(options){var method=options.method,path=options.path,_a=options.params,params=_a===void 0?{}:_a;var _b=this.configure,apiKey=_b.apiKey,accessToken=_b.accessToken,timeout=_b.timeout;var query=apiKey?{apiKey:apiKey}:{};var init={method:method,headers:{}};if(timeout){init["timeout"]=timeout}if(!apiKey&&accessToken){init.headers["Authorization"]="Bearer "+accessToken}if(typeof window!=="undefined"){init.mode="cors"}if(method!=="GET"){if(params instanceof FormData){init.body=params}else{init.headers["Content-type"]="application/x-www-form-urlencoded";init.body=this.toQueryString(params)}}else{Object.keys(params).forEach(function(key){return query[key]=params[key]})}var qs=this.toQueryString(query);var url=this.restBaseURL+"/"+path+(qs.length>0?"?"+qs:"");return fetch(url,init).then(this.checkStatus)};Request.prototype.checkStatus=function(response){return new Promise(function(resolve,reject){if(200<=response.status&&response.status<300){resolve(response)}else{response.json().then(function(data){if(response.status===401){reject(new Error.BacklogAuthError(response,data))}else{reject(new Error.BacklogApiError(response,data))}}).catch(function(err){return reject(new Error.UnexpectedError(response))})}})};Request.prototype.parseJSON=function(response){return response.json()};Request.prototype.toQueryString=function(params){return Object.keys(params).reduce(function(result,key){var value=params[key];if(!value){return result}if(Array.isArray(value)){value.forEach(function(v){return result.push(key+"[]="+v)})}else{result.push(key+"="+value)}return result},[]).join("&")};Object.defineProperty(Request.prototype,"webAppBaseURL",{get:function(){return"https://"+this.configure.host},enumerable:true,configurable:true});Object.defineProperty(Request.prototype,"restBaseURL",{get:function(){return this.webAppBaseURL+"/api/v2"},enumerable:true,configurable:true});return Request}();exports.default=Request},{"./error":3}]},{},[4])(4)}); \ No newline at end of file