Skip to content

Commit

Permalink
Add responce types for PullRequest, Git, WatchingList #28
Browse files Browse the repository at this point in the history
  • Loading branch information
mmktomato committed May 30, 2023
1 parent b794054 commit 71f7802
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 28 deletions.
28 changes: 14 additions & 14 deletions dist/types/backlog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,31 +477,31 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-git-repositories/
*/
getGitRepositories(projectIdOrKey: string | number): Promise<any>;
getGitRepositories(projectIdOrKey: string | number): Promise<Entity.Git.GitRepository[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-git-repository/
*/
getGitRepository(projectIdOrKey: string | number, repoIdOrName: string): Promise<any>;
getGitRepository(projectIdOrKey: string | number, repoIdOrName: string): Promise<Entity.Git.GitRepository>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-pull-request-list/
*/
getPullRequests(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise<any>;
getPullRequests(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise<Entity.PullRequest.PullRequest[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-number-of-pull-requests/
*/
getPullRequestsCount(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise<any>;
getPullRequestsCount(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise<Entity.PullRequest.PullRequestCount>;
/**
* https://developer.nulab.com/docs/backlog/api/2/add-pull-request/
*/
postPullRequest(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.PostPullRequestParams): Promise<any>;
postPullRequest(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.PostPullRequestParams): Promise<Entity.PullRequest.PullRequest>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-pull-request/
*/
getPullRequest(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise<any>;
getPullRequest(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise<Entity.PullRequest.PullRequest>;
/**
* https://developer.nulab.com/docs/backlog/api/2/update-pull-request/
*/
patchPullRequest(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.PatchPullRequestParams): Promise<any>;
patchPullRequest(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.PatchPullRequestParams): Promise<Entity.PullRequest.PullRequest>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-pull-request-comment/
*/
Expand Down Expand Up @@ -533,31 +533,31 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-watching-list
*/
getWatchingListItems(userId: number): Promise<any>;
getWatchingListItems(userId: number): Promise<Entity.WatchingList.WatchingListItem[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/count-watching
*/
getWatchingListCount(userId: number): Promise<any>;
getWatchingListCount(userId: number): Promise<Entity.WatchingList.WatchingListCount>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-watching
*/
getWatchingListItem(watchId: number): Promise<any>;
getWatchingListItem(watchId: number): Promise<Entity.WatchingList.WatchingListItem>;
/**
* https://developer.nulab.com/docs/backlog/api/2/add-watching
*/
postWatchingListItem(params: any): Promise<any>;
postWatchingListItem(params: any): Promise<Entity.WatchingList.WatchingListItem>;
/**
* https://developer.nulab.com/docs/backlog/api/2/update-watching
*/
patchWatchingListItem(watchId: number, note: string): Promise<any>;
patchWatchingListItem(watchId: number, note: string): Promise<Entity.WatchingList.WatchingListItem>;
/**
* https://developer.nulab.com/docs/backlog/api/2/delete-watching
*/
deletehWatchingListItem(watchId: number): Promise<any>;
deletehWatchingListItem(watchId: number): Promise<Entity.WatchingList.WatchingListItem>;
/**
* https://developer.nulab.com/docs/backlog/api/2/mark-watching-as-read
*/
resetWatchingListItemAsRead(watchId: number): Promise<undefined>;
resetWatchingListItemAsRead(watchId: number): Promise<void>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-project-group-list
* @deprecated
Expand Down
63 changes: 63 additions & 0 deletions dist/types/entity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,34 @@ export declare namespace Wiki {
}
}
export declare namespace PullRequest {
interface Status {
id: number;
name: string;
}
interface PullRequest {
id: number;
projectId: number;
repositoryId: number;
number: number;
summary: string;
description: string;
base: string;
branch: string;
status: Status;
assignee: User.User;
issue: Issue.Issue;
baseCommit?: string;
branchCommit?: string;
mergeCommit?: string;
closeAt?: string;
mergeAt?: string;
createdUser: User.User;
created: string;
updatedUser: User.User;
updated: string;
attachments: File.PullRequestFileInfo[];
stars: Star.Star[];
}
interface Comment {
id: number;
content: string;
Expand All @@ -317,6 +345,9 @@ export declare namespace PullRequest {
stars: Star.Star[];
notifications: CommentNotification.CommentNotification[];
}
interface PullRequestCount {
count: number;
}
interface PullRequestCommentCount {
count: number;
}
Expand Down Expand Up @@ -345,3 +376,35 @@ export declare namespace ChangeLog {
}
type PullRequestChangeLog = ChangeLog;
}
export declare namespace Git {
interface GitRepository {
id: number;
projectId: number;
name: string;
description: string;
hookUrl?: string;
httpUrl: string;
sshUrl: string;
displayOrder: number;
pushedAt?: string;
createdUser: User.User;
created: string;
updatedUser: User.User;
updated: string;
}
}
export declare namespace WatchingList {
interface WatchingListItem {
id: number;
resourceAlreadyRead: boolean;
note: string;
type: string;
issue: Issue.Issue;
lastContentUpdated: string;
created: string;
updated: string;
}
interface WatchingListCount {
count: number;
}
}
28 changes: 14 additions & 14 deletions src/backlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-git-repositories/
*/
public getGitRepositories(projectIdOrKey: string | number): Promise<any> {
public getGitRepositories(projectIdOrKey: string | number): Promise<Entity.Git.GitRepository[]> {
return this.get(`projects/${projectIdOrKey}/git/repositories`);
}

Expand All @@ -946,7 +946,7 @@ export default class Backlog extends Request {
*/
public getGitRepository(
projectIdOrKey: string | number, repoIdOrName: string
): Promise<any> {
): Promise<Entity.Git.GitRepository> {
return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}`);
}

Expand All @@ -957,7 +957,7 @@ export default class Backlog extends Request {
projectIdOrKey: string | number,
repoIdOrName: string,
params: Option.PullRequest.GetPullRequestsParams
): Promise<any> {
): Promise<Entity.PullRequest.PullRequest[]> {
return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests`, params);
}

Expand All @@ -968,7 +968,7 @@ export default class Backlog extends Request {
projectIdOrKey: string | number,
repoIdOrName: string,
params: Option.PullRequest.GetPullRequestsParams
): Promise<any> {
): Promise<Entity.PullRequest.PullRequestCount> {
return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/count`, params);
}

Expand All @@ -979,7 +979,7 @@ export default class Backlog extends Request {
projectIdOrKey: string | number,
repoIdOrName: string,
params: Option.PullRequest.PostPullRequestParams
): Promise<any> {
): Promise<Entity.PullRequest.PullRequest> {
return this.post(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests`, params);
}

Expand All @@ -988,7 +988,7 @@ export default class Backlog extends Request {
*/
public getPullRequest(
projectIdOrKey: string | number, repoIdOrName: string, number: number
): Promise<any> {
): Promise<Entity.PullRequest.PullRequest> {
return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}`);
}

Expand All @@ -1000,7 +1000,7 @@ export default class Backlog extends Request {
repoIdOrName: string,
number: number,
params: Option.PullRequest.PatchPullRequestParams
): Promise<any> {
): Promise<Entity.PullRequest.PullRequest> {
return this.patch(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}`, params);
}

Expand Down Expand Up @@ -1080,49 +1080,49 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-watching-list
*/
public getWatchingListItems(userId: number): Promise<any> {
public getWatchingListItems(userId: number): Promise<Entity.WatchingList.WatchingListItem[]> {
return this.get(`users/${userId}/watchings`);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/count-watching
*/
public getWatchingListCount(userId: number): Promise<any> {
public getWatchingListCount(userId: number): Promise<Entity.WatchingList.WatchingListCount> {
return this.get(`users/${userId}/watchings/count`);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/get-watching
*/
public getWatchingListItem(watchId: number): Promise<any> {
public getWatchingListItem(watchId: number): Promise<Entity.WatchingList.WatchingListItem> {
return this.get(`watchings/${watchId}`);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/add-watching
*/
public postWatchingListItem(params: any): Promise<any> {
public postWatchingListItem(params: any): Promise<Entity.WatchingList.WatchingListItem> {
return this.post(`watchings`, params);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/update-watching
*/
public patchWatchingListItem(watchId: number, note: string): Promise<any> {
public patchWatchingListItem(watchId: number, note: string): Promise<Entity.WatchingList.WatchingListItem> {
return this.patch(`watchings/${watchId}`, { note });
}

/**
* https://developer.nulab.com/docs/backlog/api/2/delete-watching
*/
public deletehWatchingListItem(watchId: number): Promise<any> {
public deletehWatchingListItem(watchId: number): Promise<Entity.WatchingList.WatchingListItem> {
return this.delete(`watchings/${watchId}`);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/mark-watching-as-read
*/
public resetWatchingListItemAsRead(watchId: number): Promise<undefined> {
public resetWatchingListItemAsRead(watchId: number): Promise<void> {
return this.post(`watchings/${watchId}/markAsRead`);
}

Expand Down
69 changes: 69 additions & 0 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,36 @@ export namespace Wiki {
}

export namespace PullRequest {
export interface Status {
id: number;
name: string;
}

export interface PullRequest {
id: number;
projectId: number;
repositoryId: number;
number: number;
summary: string;
description: string;
base: string;
branch: string;
status: Status;
assignee: User.User;
issue: Issue.Issue;
baseCommit?: string;
branchCommit?: string;
mergeCommit?: string;
closeAt?: string;
mergeAt?: string;
createdUser: User.User;
created: string;
updatedUser: User.User;
updated: string;
attachments: File.PullRequestFileInfo[];
stars: Star.Star[];
}

export interface Comment {
id: number;
content: string;
Expand All @@ -365,6 +395,10 @@ export namespace PullRequest {
notifications: CommentNotification.CommentNotification[];
}

export interface PullRequestCount {
count: number;
}

export interface PullRequestCommentCount {
count: number;
}
Expand Down Expand Up @@ -398,4 +432,39 @@ export namespace ChangeLog {
}

export type PullRequestChangeLog = ChangeLog;
}

export namespace Git {
export interface GitRepository {
id: number;
projectId: number;
name: string;
description: string;
hookUrl?: string;
httpUrl: string;
sshUrl: string;
displayOrder: number;
pushedAt?: string;
createdUser: User.User;
created: string;
updatedUser: User.User;
updated: string;
}
}

export namespace WatchingList {
export interface WatchingListItem {
id: number;
resourceAlreadyRead: boolean;
note: string;
type: string;
issue: Issue.Issue;
lastContentUpdated: string;
created: string;
updated: string;
}

export interface WatchingListCount {
count: number;
}
}

0 comments on commit 71f7802

Please sign in to comment.