Download frontend/src/api/github.ts from ar08/zzz: direct link, hf CLI and curl.
- Browser
- Download file 1.9 kB
-
https://huggingface.co/spaces/ar08/zzz/resolve/main/frontend/src/api/github.ts
- Command line
-
hf download hf://spaces/ar08/zzz/frontend/src/api/github.ts
-
curl -L -o github.ts https://huggingface.co/spaces/ar08/zzz/resolve/main/frontend/src/api/github.ts
1.9 kB
| import { extractNextPageFromLink } from "#/utils/extract-next-page-from-link"; | |
| import { openHands } from "./open-hands-axios"; | |
| /** | |
| * Retrieves repositories where OpenHands Github App has been installed | |
| * @param installationIndex Pagination cursor position for app installation IDs | |
| * @param installations Collection of all App installation IDs for OpenHands Github App | |
| * @returns A list of repositories | |
| */ | |
| export const retrieveGitHubAppRepositories = async ( | |
| installationIndex: number, | |
| installations: number[], | |
| page = 1, | |
| per_page = 30, | |
| ) => { | |
| const installationId = installations[installationIndex]; | |
| const response = await openHands.get<GitHubAppRepository>( | |
| "/api/github/repositories", | |
| { | |
| params: { | |
| sort: "pushed", | |
| page, | |
| per_page, | |
| installation_id: installationId, | |
| }, | |
| }, | |
| ); | |
| const link = response.headers.link ?? ""; | |
| const nextPage = extractNextPageFromLink(link); | |
| let nextInstallation: number | null; | |
| if (nextPage) { | |
| nextInstallation = installationIndex; | |
| } else if (installationIndex + 1 < installations.length) { | |
| nextInstallation = installationIndex + 1; | |
| } else { | |
| nextInstallation = null; | |
| } | |
| return { | |
| data: response.data.repositories, | |
| nextPage, | |
| installationIndex: nextInstallation, | |
| }; | |
| }; | |
| /** | |
| * Given a PAT, retrieves the repositories of the user | |
| * @returns A list of repositories | |
| */ | |
| export const retrieveGitHubUserRepositories = async ( | |
| page = 1, | |
| per_page = 30, | |
| ) => { | |
| const response = await openHands.get<GitHubRepository[]>( | |
| "/api/github/repositories", | |
| { | |
| params: { | |
| sort: "pushed", | |
| page, | |
| per_page, | |
| }, | |
| }, | |
| ); | |
| const link = response.headers.link ?? ""; | |
| const nextPage = extractNextPageFromLink(link); | |
| return { data: response.data, nextPage }; | |
| }; | |