diff --git a/package.json b/package.json index d48903906..ccfb68f49 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1bafebed9..8c8a79d27 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,6 +51,9 @@ importers: '@octokit/openapi-types': specifier: 27.0.0 version: 27.0.0 + '@octokit/types': + specifier: ^16.0.0 + version: 16.0.0 '@parcel/watcher': specifier: 2.5.1 version: 2.5.1 @@ -1620,6 +1623,9 @@ packages: '@octokit/openapi-types@27.0.0': resolution: {integrity: sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==} + '@octokit/types@16.0.0': + resolution: {integrity: sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==} + '@oddbird/popover-polyfill@0.5.2': resolution: {integrity: sha512-iFrvar5SOMtKFOSjYvs4z9UlLqDdJbMx0mgISLcPedv+g0ac5sgeETLGtipHCVIae6HJPclNEH5aCyD1RZaEHw==} @@ -7880,6 +7886,10 @@ snapshots: '@octokit/openapi-types@27.0.0': {} + '@octokit/types@16.0.0': + dependencies: + '@octokit/openapi-types': 27.0.0 + '@oddbird/popover-polyfill@0.5.2': {} '@parcel/watcher-android-arm64@2.5.1': diff --git a/src/renderer/utils/api/client.ts b/src/renderer/utils/api/client.ts index c77ddbc80..5015565e8 100644 --- a/src/renderer/utils/api/client.ts +++ b/src/renderer/utils/api/client.ts @@ -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, @@ -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 { +): AxiosPromise { const url = getGitHubAPIBaseUrl(account.hostname); url.pathname += 'notifications'; url.searchParams.append('participating', String(settings.participating)); @@ -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 { +): AxiosPromise { const url = getGitHubAPIBaseUrl(hostname); url.pathname += `notifications/threads/${threadId}`; @@ -111,7 +115,7 @@ export function markNotificationThreadAsDone( threadId: string, hostname: Hostname, token: Token, -): AxiosPromise { +): AxiosPromise { const url = getGitHubAPIBaseUrl(hostname); url.pathname += `notifications/threads/${threadId}`; @@ -127,7 +131,7 @@ export function ignoreNotificationThreadSubscription( threadId: string, hostname: Hostname, token: Token, -): AxiosPromise { +): AxiosPromise { const url = getGitHubAPIBaseUrl(hostname); url.pathname += `notifications/threads/${threadId}/subscription`; @@ -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 { +export function getCommit( + url: Link, + token: Token, +): AxiosPromise { 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 { +): AxiosPromise { return apiRequestAuth(url, 'GET', token); } @@ -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 { +export function getRelease( + url: Link, + token: Token, +): AxiosPromise { return apiRequestAuth(url, 'GET', token); } diff --git a/src/renderer/utils/api/types.ts b/src/renderer/utils/api/types.ts index 2ada18d0b..f184df434 100644 --- a/src/renderer/utils/api/types.ts +++ b/src/renderer/utils/api/types.ts @@ -1,4 +1,4 @@ -import type { components } from '@octokit/openapi-types'; +import type { Endpoints } from '@octokit/types'; import type { Link } from '../../types'; @@ -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'];