Skip to content

Commit

Permalink
Merge pull request #8 from toshimaru/iresponse-to-response
Browse files Browse the repository at this point in the history
Bump TypeScript to v2.9 / Use @types/isomorphic-fetch
  • Loading branch information
vvatanabe authored Aug 28, 2020
2 parents 7b10eea + eeb1c38 commit 19a40ce
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 67 deletions.
24 changes: 12 additions & 12 deletions dist/backlog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ declare module 'backlog-js' {
method: string;
path: string;
params?: Params | FormData;
}): Promise<IResponse>;
checkStatus(response: IResponse): Promise<IResponse>;
parseJSON<T>(response: IResponse): Promise<T>;
}): Promise<Response>;
checkStatus(response: Response): Promise<Response>;
parseJSON<T>(response: Response): Promise<T>;
private toFormData(params);
private toQueryString(params);
webAppBaseURL: string;
Expand All @@ -43,7 +43,7 @@ declare module 'backlog-js' {
putSpaceNotification(params: Option.Space.PutSpaceNotificationParams): Promise<any>;
getSpaceDiskUsage(): Promise<any>;
getSpaceIcon(): Promise<Entity.File.FileData>;
postSpaceAttachment(form: FormData): Promise<IResponse>;
postSpaceAttachment(form: FormData): Promise<any>;
getUsers(): Promise<any>;
getUser(userId: number): Promise<any>;
postUser(params: Option.User.PostUserParams): Promise<any>;
Expand Down Expand Up @@ -158,9 +158,9 @@ declare module 'backlog-js' {
getIssueAttachment(issueIdOrKey: string, attachmentId: number): Promise<Entity.File.FileData>;
getWikiAttachment(wikiId: number, attachmentId: number): Promise<Entity.File.FileData>;
getPullRequestAttachment(projectIdOrKey: string, repoIdOrName: string, number: number, attachmentId: number): Promise<Entity.File.FileData>;
private download(path);
private upload(path, params);
private parseFileData(response);
private download;
private upload;
private parseFileData;
}

export class OAuth2 {
Expand Down Expand Up @@ -650,7 +650,7 @@ declare module 'backlog-js' {
private _status;
private _body;
private _response;
constructor(name: BacklogErrorNameType, response: IResponse, body?: {
constructor(name: BacklogErrorNameType, response: Response, body?: {
errors: BacklogErrorMessage[];
});
name: BacklogErrorNameType;
Expand All @@ -659,20 +659,20 @@ declare module 'backlog-js' {
body: {
errors: BacklogErrorMessage[];
};
response: IResponse;
response: Response;
}
export class BacklogApiError extends BacklogError {
constructor(response: IResponse, body?: {
constructor(response: Response, body?: {
errors: BacklogErrorMessage[];
});
}
export class BacklogAuthError extends BacklogError {
constructor(response: IResponse, body?: {
constructor(response: Response, body?: {
errors: BacklogErrorMessage[];
});
}
export class UnexpectedError extends BacklogError {
constructor(response: IResponse);
constructor(response: Response);
}
export interface BacklogErrorMessage {
message: string;
Expand Down
97 changes: 56 additions & 41 deletions dist/backlog.js
Original file line number Diff line number Diff line change
@@ -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<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var request_1 = require('./request');
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var request_1 = require("./request");
var Backlog = (function (_super) {
__extends(Backlog, _super);
function Backlog(configure) {
_super.call(this, configure);
return _super.call(this, configure) || this;
}
Backlog.prototype.getSpace = function () {
return this.get('space');
Expand Down Expand Up @@ -403,29 +409,36 @@ var Backlog = (function (_super) {
};
return Backlog;
}(request_1.default));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Backlog;

},{"./request":7}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

},{}],3:[function(require,module,exports){
(function (global){
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var BacklogError = (function (_super) {
__extends(BacklogError, _super);
function BacklogError(name, response, body) {
_super.call(this, response.statusText);
this._name = name;
this._url = response.url;
this._status = response.status;
this._body = body;
this._response = response;
var _this = _super.call(this, response.statusText) || this;
_this._name = name;
_this._url = response.url;
_this._status = response.status;
_this._body = body;
_this._response = response;
return _this;
}
Object.defineProperty(BacklogError.prototype, "name", {
get: function () {
Expand Down Expand Up @@ -468,23 +481,23 @@ exports.BacklogError = BacklogError;
var BacklogApiError = (function (_super) {
__extends(BacklogApiError, _super);
function BacklogApiError(response, body) {
_super.call(this, 'BacklogApiError', response, body);
return _super.call(this, 'BacklogApiError', response, body) || this;
}
return BacklogApiError;
}(BacklogError));
exports.BacklogApiError = BacklogApiError;
var BacklogAuthError = (function (_super) {
__extends(BacklogAuthError, _super);
function BacklogAuthError(response, body) {
_super.call(this, 'BacklogAuthError', response, body);
return _super.call(this, 'BacklogAuthError', response, body) || this;
}
return BacklogAuthError;
}(BacklogError));
exports.BacklogAuthError = BacklogAuthError;
var UnexpectedError = (function (_super) {
__extends(UnexpectedError, _super);
function UnexpectedError(response) {
_super.call(this, 'UnexpectedError', response);
return _super.call(this, 'UnexpectedError', response) || this;
}
return UnexpectedError;
}(BacklogError));
Expand All @@ -493,20 +506,22 @@ exports.UnexpectedError = UnexpectedError;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],4:[function(require,module,exports){
"use strict";
var backlog_1 = require('./backlog');
Object.defineProperty(exports, "__esModule", { value: true });
var backlog_1 = require("./backlog");
exports.Backlog = backlog_1.default;
var oauth2_1 = require('./oauth2');
var oauth2_1 = require("./oauth2");
exports.OAuth2 = oauth2_1.default;
var Option = require('./option');
var Option = require("./option");
exports.Option = Option;
var Entity = require('./entity');
var Entity = require("./entity");
exports.Entity = Entity;
var Error = require('./error');
var Error = require("./error");
exports.Error = Error;

},{"./backlog":1,"./entity":2,"./error":3,"./oauth2":5,"./option":6}],5:[function(require,module,exports){
"use strict";
var request_1 = require('./request');
Object.defineProperty(exports, "__esModule", { value: true });
var request_1 = require("./request");
var OAuth2 = (function () {
function OAuth2(credentials, timeout) {
this.credentials = credentials;
Expand All @@ -519,7 +534,7 @@ var OAuth2 = (function () {
redirect_uri: options.redirectUri,
state: options.state
};
return ("https://" + options.host + "/OAuth2AccessRequest.action?") +
return "https://" + options.host + "/OAuth2AccessRequest.action?" +
Object.keys(params)
.map(function (key) { return params[key] ? key + "=" + params[key] : ''; })
.filter(function (x) { return x.length > 0; })
Expand Down Expand Up @@ -548,11 +563,12 @@ var OAuth2 = (function () {
};
return OAuth2;
}());
Object.defineProperty(exports, "__esModule", { value: true });
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";
Expand All @@ -576,22 +592,22 @@ exports.default = OAuth2;
ActivityType[ActivityType["PullRequestUpdated"] = 19] = "PullRequestUpdated";
ActivityType[ActivityType["PullRequestCommented"] = 20] = "PullRequestCommented";
ActivityType[ActivityType["PullRequestMerged"] = 21] = "PullRequestMerged";
})(exports.ActivityType || (exports.ActivityType = {}));
var ActivityType = exports.ActivityType;
})(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";
})(User.RoleType || (User.RoleType = {}));
var RoleType = User.RoleType;
})(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";
Expand All @@ -601,24 +617,24 @@ var Project;
FieldType[FieldType["MultipleList"] = 6] = "MultipleList";
FieldType[FieldType["CheckBox"] = 7] = "CheckBox";
FieldType[FieldType["Radio"] = 8] = "Radio";
})(Project.FieldType || (Project.FieldType = {}));
var FieldType = Project.FieldType;
})(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";
})(Issue.ParentChildType || (Issue.ParentChildType = {}));
var ParentChildType = Issue.ParentChildType;
})(ParentChildType = Issue.ParentChildType || (Issue.ParentChildType = {}));
})(Issue = exports.Issue || (exports.Issue = {}));

},{}],7:[function(require,module,exports){
"use strict";
var Error = require('./error');
Object.defineProperty(exports, "__esModule", { value: true });
var Error = require("./error");
var Request = (function () {
function Request(configure) {
this.configure = configure;
Expand Down Expand Up @@ -665,7 +681,7 @@ var Request = (function () {
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 : '');
var url = this.restBaseURL + "/" + path + (qs.length > 0 ? "?" + qs : '');
return fetch(url, init).then(this.checkStatus);
};
Request.prototype.checkStatus = function (response) {
Expand Down Expand Up @@ -719,7 +735,6 @@ var Request = (function () {
});
return Request;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Request;

},{"./error":3}]},{},[4])(4)
Expand Down
2 changes: 1 addition & 1 deletion dist/backlog.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"author": "vvatanabe",
"license": "MIT",
"devDependencies": {
"@types/isomorphic-fetch": "0.0.35",
"browserify": "^13.0.1",
"coveralls": "^2.11.9",
"dotenv": "^2.0.0",
Expand All @@ -32,7 +33,7 @@
"nock": "^8.0.0",
"power-assert": "^1.4.1",
"qs": "^6.2.1",
"typescript": "^1.8.10",
"typescript": "^2.9.2",
"uglify-js": "^2.6.2"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/backlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,11 @@ export default class Backlog extends Request {
return this.request({ method: 'GET', path }).then(this.parseFileData);
}

private upload(path: string, params: FormData): Promise<IResponse> {
private upload(path: string, params: FormData): Promise<any> {
return this.request({ method: 'POST', path, params }).then(this.parseJSON);
}

private parseFileData(response: IResponse): Promise<Entity.File.FileData> {
private parseFileData(response: Response): Promise<Entity.File.FileData> {
return new Promise((resolve, reject) => {
if (typeof window !== 'undefined') {
resolve({
Expand Down
12 changes: 6 additions & 6 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export class BacklogError extends global.Error {
private _url: string;
private _status: number;
private _body: { errors: BacklogErrorMessage[] };
private _response: IResponse;
private _response: Response;
constructor(
name: BacklogErrorNameType,
response: IResponse,
response: Response,
body?: { errors: BacklogErrorMessage[] }
) {
super(response.statusText);
Expand All @@ -29,14 +29,14 @@ export class BacklogError extends global.Error {
get body(): { errors: BacklogErrorMessage[] } {
return this._body;
}
get response(): IResponse {
get response(): Response {
return this._response;
}
}

export class BacklogApiError extends BacklogError {
constructor(
response: IResponse,
response: Response,
body?: { errors: BacklogErrorMessage[] }
) {
super('BacklogApiError', response, body);
Expand All @@ -45,7 +45,7 @@ export class BacklogApiError extends BacklogError {

export class BacklogAuthError extends BacklogError {
constructor(
response: IResponse,
response: Response,
body?: { errors: BacklogErrorMessage[] }
) {
super('BacklogAuthError', response, body);
Expand All @@ -54,7 +54,7 @@ export class BacklogAuthError extends BacklogError {

export class UnexpectedError extends BacklogError {
constructor(
response: IResponse
response: Response
) {
super('UnexpectedError', response);
}
Expand Down
Loading

0 comments on commit 19a40ce

Please sign in to comment.