mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-04 17:18:35 +02:00
* feat(github): import repositories from app installations Co-authored-by: multica-agent <github@multica.ai> * fix(github): address repository import review nits Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: Eve <eve@multica-ai.local> Co-authored-by: multica-agent <github@multica.ai>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { infiniteQueryOptions, queryOptions } from "@tanstack/react-query";
|
|
import { api } from "../api";
|
|
|
|
export const githubKeys = {
|
|
all: (wsId: string) => ["github", wsId] as const,
|
|
installations: (wsId: string) => [...githubKeys.all(wsId), "installations"] as const,
|
|
repositories: (wsId: string, installationId: string) =>
|
|
[...githubKeys.all(wsId), "installations", installationId, "repositories"] as const,
|
|
pullRequests: (issueId: string) => ["github", "pull-requests", issueId] as const,
|
|
};
|
|
|
|
export const githubInstallationsOptions = (wsId: string) =>
|
|
queryOptions({
|
|
queryKey: githubKeys.installations(wsId),
|
|
queryFn: () => api.listGitHubInstallations(wsId),
|
|
enabled: !!wsId,
|
|
});
|
|
|
|
export const githubInstallationRepositoriesOptions = (
|
|
wsId: string,
|
|
installationId: string,
|
|
) =>
|
|
infiniteQueryOptions({
|
|
queryKey: githubKeys.repositories(wsId, installationId),
|
|
queryFn: ({ pageParam }) =>
|
|
api.listGitHubInstallationRepositories(wsId, installationId, {
|
|
page: pageParam,
|
|
per_page: 100,
|
|
}),
|
|
initialPageParam: 1,
|
|
getNextPageParam: (lastPage) => lastPage.next_page ?? undefined,
|
|
enabled: !!wsId && !!installationId,
|
|
});
|
|
|
|
export const issuePullRequestsOptions = (issueId: string) =>
|
|
queryOptions({
|
|
queryKey: githubKeys.pullRequests(issueId),
|
|
queryFn: () => api.listIssuePullRequests(issueId),
|
|
enabled: !!issueId,
|
|
});
|