This commit is contained in:
parent
1fc88f8166
commit
8c5d70a5f7
7 changed files with 23 additions and 1 deletions
|
@ -7,7 +7,7 @@
|
||||||
"build": "swc ./src/index.ts -o dist/index.js",
|
"build": "swc ./src/index.ts -o dist/index.js",
|
||||||
"lint": "prettier --write ./src/*",
|
"lint": "prettier --write ./src/*",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"doc": "typedoc ./src/index.ts"
|
"doc": "typedoc ./src/index.ts ./src/auth.ts ./src/spec/**"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
@ -32,6 +32,9 @@ class Forgejo {
|
||||||
this.token = new Auth(token);
|
this.token = new Auth(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get access token
|
||||||
|
*/
|
||||||
getTokenAuth(): Auth {
|
getTokenAuth(): Auth {
|
||||||
if (this.token) {
|
if (this.token) {
|
||||||
return this.token;
|
return this.token;
|
||||||
|
@ -40,6 +43,9 @@ class Forgejo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get access token in header format for the fetch API
|
||||||
|
*/
|
||||||
getTokenAuthHeader() {
|
getTokenAuthHeader() {
|
||||||
return { Authorization: `token ${this.getTokenAuth().getToken()}` };
|
return { Authorization: `token ${this.getTokenAuth().getToken()}` };
|
||||||
}
|
}
|
||||||
|
@ -201,6 +207,9 @@ class Forgejo {
|
||||||
return issue;
|
return issue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch and save comments for the issue objects
|
||||||
|
*/
|
||||||
async getCommentsForIssue(issue: Issue): Promise<Issue> {
|
async getCommentsForIssue(issue: Issue): Promise<Issue> {
|
||||||
// TODO: check if issue.number != issue.id causes problems. I'm assuming
|
// TODO: check if issue.number != issue.id causes problems. I'm assuming
|
||||||
// Issue.number is the local repository issue ID and issue.id is DB ID
|
// Issue.number is the local repository issue ID and issue.id is DB ID
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
import User from "./user";
|
import User from "./user";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subset schema of comment object returned by Forgejo REST API
|
||||||
|
*/
|
||||||
type Comment = {
|
type Comment = {
|
||||||
id: number;
|
id: number;
|
||||||
html_url: URL;
|
html_url: URL;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
import User from "./user";
|
import User from "./user";
|
||||||
import Comment from "./comments";
|
import Comment from "./comments";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subset schema of issue object returned by Forgejo REST API
|
||||||
|
*/
|
||||||
type Issue = {
|
type Issue = {
|
||||||
id: number;
|
id: number;
|
||||||
url: URL;
|
url: URL;
|
||||||
|
|
|
@ -13,6 +13,9 @@ type Subject = {
|
||||||
state: string;
|
state: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subset schema of notification object returned by Forgejo REST API
|
||||||
|
*/
|
||||||
type Notification = {
|
type Notification = {
|
||||||
id: number;
|
id: number;
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
import User from "./user";
|
import User from "./user";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subset schema of repository object returned by Forgejo REST API
|
||||||
|
*/
|
||||||
type Repository = {
|
type Repository = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
/** Subset schema of user object returned by Forgejo REST API. */
|
||||||
type User = {
|
type User = {
|
||||||
id: number;
|
id: number;
|
||||||
login: string;
|
login: string;
|
||||||
|
|
Loading…
Reference in a new issue