From 506aaaf16dc6f82388ab6b928920ee4c5e3b0e6d Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 18 Sep 2023 20:28:06 +0530 Subject: [PATCH] feat: add Forgejo API response type defs --- src/spec/comments.ts | 14 ++++++++++++++ src/spec/issue.ts | 32 ++++++++++++++++++++++++++++++++ src/spec/notification.ts | 20 ++++++++++++++++++++ src/spec/owner.ts | 8 ++++++++ src/spec/repository.ts | 11 +++++++++++ src/spec/user.ts | 11 +++++++++++ 6 files changed, 96 insertions(+) create mode 100644 src/spec/comments.ts create mode 100644 src/spec/issue.ts create mode 100644 src/spec/notification.ts create mode 100644 src/spec/owner.ts create mode 100644 src/spec/repository.ts create mode 100644 src/spec/user.ts diff --git a/src/spec/comments.ts b/src/spec/comments.ts new file mode 100644 index 0000000..c545b04 --- /dev/null +++ b/src/spec/comments.ts @@ -0,0 +1,14 @@ +import User from "./user"; + +type Comment = { + id: number; + html_url: URL; + pull_request_url?: URL; + issue_url?: URL; + user: User; + body: string; + created_at: string | Date; + updated_at: string | Date; +}; + +export default Comment; diff --git a/src/spec/issue.ts b/src/spec/issue.ts new file mode 100644 index 0000000..cccc1fd --- /dev/null +++ b/src/spec/issue.ts @@ -0,0 +1,32 @@ +import User from "./user"; +import Comment from "./comments"; + +type Issue = { + id: number; + url: URL; + html_url: URL; + number: 1; + user: User; + title: string; + body: string; + assignee?: User; + assignees?: Array; + state: string; + is_locked: boolean; + comments: number; + created_at: string | Date; + updated_at: string | Date; + closed_at?: string | Date; + due_date?: string; + repository: MiniRepository; + lazy_comments_data?: Array; +}; + +type MiniRepository = { + id: number; + name: string; + owner: string; + full_name: string; +}; + +export default Issue; diff --git a/src/spec/notification.ts b/src/spec/notification.ts new file mode 100644 index 0000000..fd6df05 --- /dev/null +++ b/src/spec/notification.ts @@ -0,0 +1,20 @@ +import Repository from "./repository"; + +type Subject = { + title: string; + url: URL; + latest_comment_url: string; + type: string; // Issue + state: string; +}; + +type Notification = { + id: number; + repository: Repository; + subject: Subject; + unread: boolean; + pinned: boolean; + url: URL; +}; + +export default Notification; diff --git a/src/spec/owner.ts b/src/spec/owner.ts new file mode 100644 index 0000000..b5755f5 --- /dev/null +++ b/src/spec/owner.ts @@ -0,0 +1,8 @@ +type Repository = { + id: number; + name: string; + full_name: string; + html_url: string; +}; + +export default Repository; diff --git a/src/spec/repository.ts b/src/spec/repository.ts new file mode 100644 index 0000000..1f63132 --- /dev/null +++ b/src/spec/repository.ts @@ -0,0 +1,11 @@ +import User from "./user"; + +type Repository = { + id: number; + name: string; + full_name: string; + html_url: string; + owner: User; +}; + +export default Repository; diff --git a/src/spec/user.ts b/src/spec/user.ts new file mode 100644 index 0000000..df6a8e9 --- /dev/null +++ b/src/spec/user.ts @@ -0,0 +1,11 @@ +type User = { + id: number; + login: string; + username: string; + email: string; + avatar_url: URL; + full_name: string; + html_url: string; +}; + +export default User;