UI Update
Some checks failed
Build and Release / Test (push) Has been cancelled
Build and Release / Build Windows (push) Has been cancelled
Build and Release / Build Linux (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
Build and Release / Create Release (push) Has been cancelled
Build and Release / Development Build (push) Has been cancelled
Some checks failed
Build and Release / Test (push) Has been cancelled
Build and Release / Build Windows (push) Has been cancelled
Build and Release / Build Linux (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
Build and Release / Create Release (push) Has been cancelled
Build and Release / Development Build (push) Has been cancelled
This commit is contained in:
102
src/lib/gitea/issue.ts
Normal file
102
src/lib/gitea/issue.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import type { AxiosInstance } from "axios";
|
||||
import type { Issue, Comment, Label, Milestone } from "./types";
|
||||
|
||||
export class IssueAPI {
|
||||
constructor(private client: AxiosInstance) {}
|
||||
|
||||
async listIssues(
|
||||
owner: string,
|
||||
repo: string,
|
||||
options?: {
|
||||
state?: "open" | "closed" | "all";
|
||||
labels?: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
},
|
||||
): Promise<Issue[]> {
|
||||
const { data } = await this.client.get<Issue[]>(`/repos/${owner}/${repo}/issues`, {
|
||||
params: options,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
async getIssue(owner: string, repo: string, index: number): Promise<Issue> {
|
||||
const { data } = await this.client.get<Issue>(`/repos/${owner}/${repo}/issues/${index}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createIssue(
|
||||
owner: string,
|
||||
repo: string,
|
||||
payload: {
|
||||
title: string;
|
||||
body?: string;
|
||||
assignees?: string[];
|
||||
labels?: number[];
|
||||
milestone?: number;
|
||||
},
|
||||
): Promise<Issue> {
|
||||
const { data } = await this.client.post<Issue>(
|
||||
`/repos/${owner}/${repo}/issues`,
|
||||
payload,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async editIssue(
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
payload: Partial<{
|
||||
title: string;
|
||||
body: string;
|
||||
state: "open" | "closed";
|
||||
assignees: string[];
|
||||
labels: number[];
|
||||
milestone: number;
|
||||
}>,
|
||||
): Promise<Issue> {
|
||||
const { data } = await this.client.patch<Issue>(
|
||||
`/repos/${owner}/${repo}/issues/${index}`,
|
||||
payload,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async listIssueComments(owner: string, repo: string, index: number): Promise<Comment[]> {
|
||||
const { data } = await this.client.get<Comment[]>(
|
||||
`/repos/${owner}/${repo}/issues/${index}/comments`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async addIssueComment(
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
body: string,
|
||||
): Promise<Comment> {
|
||||
const { data } = await this.client.post<Comment>(
|
||||
`/repos/${owner}/${repo}/issues/${index}/comments`,
|
||||
{ body },
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async listLabels(owner: string, repo: string): Promise<Label[]> {
|
||||
const { data } = await this.client.get<Label[]>(`/repos/${owner}/${repo}/labels`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async listMilestones(
|
||||
owner: string,
|
||||
repo: string,
|
||||
state?: "open" | "closed" | "all",
|
||||
): Promise<Milestone[]> {
|
||||
const { data } = await this.client.get<Milestone[]>(
|
||||
`/repos/${owner}/${repo}/milestones`,
|
||||
{ params: { state } },
|
||||
);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user