Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"@graphql-codegen/cli": "6.1.0",
"@graphql-codegen/schema-ast": "5.0.0",
"@octokit/openapi-types": "27.0.0",
"@octokit/types": "^16.0.0",
"@parcel/watcher": "2.5.1",
"@primer/css": "22.1.0",
"@primer/octicons-react": "19.21.1",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions src/renderer/utils/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import {
performGraphQLRequestString,
} from './request';
import type {
NotificationThreadSubscription,
RawCommit,
RawCommitComment,
RawGitHubNotification,
RawRelease,
GetCommitCommentResponse,
GetCommitResponse,
GetReleaseResponse,
IgnoreNotificationThreadSubscriptionResponse,
ListNotificationsForAuthenticatedUserResponse,
MarkNotificationThreadAsDoneResponse,
MarkNotificationThreadAsReadResponse,
} from './types';
import {
getGitHubAPIBaseUrl,
Expand Down Expand Up @@ -64,10 +66,11 @@ export function headNotifications(
*
* Endpoint documentation: https://docs.github.com/en/rest/activity/notifications#list-notifications-for-the-authenticated-user
*/

export function listNotificationsForAuthenticatedUser(
account: Account,
settings: SettingsState,
): AxiosPromise<RawGitHubNotification[]> {
): AxiosPromise<ListNotificationsForAuthenticatedUserResponse> {
const url = getGitHubAPIBaseUrl(account.hostname);
url.pathname += 'notifications';
url.searchParams.append('participating', String(settings.participating));
Expand All @@ -88,11 +91,12 @@ export function listNotificationsForAuthenticatedUser(
*
* Endpoint documentation: https://docs.github.com/en/rest/activity/notifications#mark-a-thread-as-read
*/

export function markNotificationThreadAsRead(
threadId: string,
hostname: Hostname,
token: Token,
): AxiosPromise<void> {
): AxiosPromise<MarkNotificationThreadAsReadResponse> {
const url = getGitHubAPIBaseUrl(hostname);
url.pathname += `notifications/threads/${threadId}`;

Expand All @@ -111,7 +115,7 @@ export function markNotificationThreadAsDone(
threadId: string,
hostname: Hostname,
token: Token,
): AxiosPromise<void> {
): AxiosPromise<MarkNotificationThreadAsDoneResponse> {
const url = getGitHubAPIBaseUrl(hostname);
url.pathname += `notifications/threads/${threadId}`;

Expand All @@ -127,7 +131,7 @@ export function ignoreNotificationThreadSubscription(
threadId: string,
hostname: Hostname,
token: Token,
): AxiosPromise<NotificationThreadSubscription> {
): AxiosPromise<IgnoreNotificationThreadSubscriptionResponse> {
const url = getGitHubAPIBaseUrl(hostname);
url.pathname += `notifications/threads/${threadId}/subscription`;

Expand All @@ -141,20 +145,22 @@ export function ignoreNotificationThreadSubscription(
*
* Endpoint documentation: https://docs.github.com/en/rest/commits/commits#get-a-commit
*/
export function getCommit(url: Link, token: Token): AxiosPromise<RawCommit> {
export function getCommit(
url: Link,
token: Token,
): AxiosPromise<GetCommitResponse> {
return apiRequestAuth(url, 'GET', token);
}

/**
* Gets a specified commit comment.
*
*
* Endpoint documentation: https://docs.github.com/en/rest/commits/comments#get-a-commit-comment

*/
export function getCommitComment(
url: Link,
token: Token,
): AxiosPromise<RawCommitComment> {
): AxiosPromise<GetCommitCommentResponse> {
return apiRequestAuth(url, 'GET', token);
}

Expand All @@ -163,7 +169,10 @@ export function getCommitComment(
*
* Endpoint documentation: https://docs.github.com/en/rest/releases/releases#get-a-release
*/
export function getRelease(url: Link, token: Token): AxiosPromise<RawRelease> {
export function getRelease(
url: Link,
token: Token,
): AxiosPromise<GetReleaseResponse> {
return apiRequestAuth(url, 'GET', token);
}

Expand Down
24 changes: 16 additions & 8 deletions src/renderer/utils/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { components } from '@octokit/openapi-types';
import type { Endpoints } from '@octokit/types';

import type { Link } from '../../types';

Expand All @@ -7,15 +7,23 @@ export interface GitHubRESTError {
documentation_url: Link;
}

export type NotificationThreadSubscription =
components['schemas']['thread-subscription'];
export type ListNotificationsForAuthenticatedUserResponse =
Endpoints['GET /notifications']['response'];

export type RawCommit = components['schemas']['commit'];
export type MarkNotificationThreadAsReadResponse =
Endpoints['PATCH /notifications/threads/{thread_id}']['response'];

export type RawCommitComment = components['schemas']['commit-comment'];
export type MarkNotificationThreadAsDoneResponse =
Endpoints['DELETE /notifications/threads/{thread_id}']['response'];

export type RawGitHubNotification = components['schemas']['thread'];
export type IgnoreNotificationThreadSubscriptionResponse =
Endpoints['PUT /notifications/threads/{thread_id}/subscription']['response'];

export type RawRelease = components['schemas']['release'];
export type GetCommitResponse =
Endpoints['GET /repos/{owner}/{repo}/commits/{ref}']['response'];

export type RawUser = components['schemas']['simple-user'];
export type GetCommitCommentResponse =
Endpoints['GET /repos/{owner}/{repo}/comments/{comment_id}']['response'];

export type GetReleaseResponse =
Endpoints['GET /repos/{owner}/{repo}/releases/{release_id}']['response'];
Loading