diff --git a/package.json b/package.json index b95c0ce..2bba396 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "swc ./src/index.ts -o dist/index.js", "lint": "prettier --write ./src/*", "test": "jest", - "doc": "typedoc ./src/index.ts" + "doc": "typedoc ./src/index.ts ./src/auth.ts ./src/spec/**" }, "keywords": [], "author": "", diff --git a/src/index.ts b/src/index.ts index 4bdbcac..8c9ee0e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,6 +32,9 @@ class Forgejo { this.token = new Auth(token); } + /** + * Get access token + */ getTokenAuth(): Auth { if (this.token) { return this.token; @@ -40,6 +43,9 @@ class Forgejo { } } + /** + * Get access token in header format for the fetch API + */ getTokenAuthHeader() { return { Authorization: `token ${this.getTokenAuth().getToken()}` }; } @@ -201,6 +207,9 @@ class Forgejo { return issue; } + /** + * Fetch and save comments for the issue objects + */ async getCommentsForIssue(issue: Issue): Promise { // 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 diff --git a/src/spec/comments.ts b/src/spec/comments.ts index 5fab9e6..383ab40 100644 --- a/src/spec/comments.ts +++ b/src/spec/comments.ts @@ -4,6 +4,9 @@ import User from "./user"; +/** + * Subset schema of comment object returned by Forgejo REST API + */ type Comment = { id: number; html_url: URL; diff --git a/src/spec/issue.ts b/src/spec/issue.ts index 50db36b..fdb293d 100644 --- a/src/spec/issue.ts +++ b/src/spec/issue.ts @@ -5,6 +5,9 @@ import User from "./user"; import Comment from "./comments"; +/** + * Subset schema of issue object returned by Forgejo REST API + */ type Issue = { id: number; url: URL; diff --git a/src/spec/notification.ts b/src/spec/notification.ts index 2da0a69..a172831 100644 --- a/src/spec/notification.ts +++ b/src/spec/notification.ts @@ -13,6 +13,9 @@ type Subject = { state: string; }; +/** + * Subset schema of notification object returned by Forgejo REST API + */ type Notification = { id: number; repository: Repository; diff --git a/src/spec/repository.ts b/src/spec/repository.ts index 1da857c..dab8b48 100644 --- a/src/spec/repository.ts +++ b/src/spec/repository.ts @@ -4,6 +4,9 @@ import User from "./user"; +/** + * Subset schema of repository object returned by Forgejo REST API + */ type Repository = { id: number; name: string; diff --git a/src/spec/user.ts b/src/spec/user.ts index 4a89d0a..ffe0ad6 100644 --- a/src/spec/user.ts +++ b/src/spec/user.ts @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +/** Subset schema of user object returned by Forgejo REST API. */ type User = { id: number; login: string;