feat: completed github org sync

This commit is contained in:
=
2025-04-28 19:48:56 +05:30
parent dbb0b28453
commit 6d2175cf9f
32 changed files with 1398 additions and 81 deletions
@@ -0,0 +1,6 @@
export {
useCreateGithubSyncOrgConfig,
useDeleteGithubSyncOrgConfig,
useUpdateGithubSyncOrgConfig
} from "./mutations";
export { githubOrgSyncConfigQueryKeys } from "./queries";
@@ -0,0 +1,42 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { githubOrgSyncConfigQueryKeys } from "./queries";
import { TCreateGithubOrgSyncDTO, TUpdateGithubOrgSyncDTO } from "./types";
export const useCreateGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dto: TCreateGithubOrgSyncDTO) => {
return apiRequest.post("/api/v1/github-org-sync-config", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
export const useUpdateGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dto: TUpdateGithubOrgSyncDTO) => {
return apiRequest.patch("/api/v1/github-org-sync-config", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
export const useDeleteGithubSyncOrgConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => {
return apiRequest.delete("/api/v1/github-org-sync-config");
},
onSuccess: () => {
queryClient.invalidateQueries(githubOrgSyncConfigQueryKeys.get());
}
});
};
@@ -0,0 +1,20 @@
import { queryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TGithubOrgSyncConfig } from "./types";
export const githubOrgSyncConfigQueryKeys = {
allKey: () => ["github-org-sync-config"],
getKey: () => [...githubOrgSyncConfigQueryKeys.allKey(), "list"],
get: () =>
queryOptions({
queryKey: githubOrgSyncConfigQueryKeys.getKey(),
queryFn: async () => {
const { data } = await apiRequest.get<{ githubOrgSyncConfig: TGithubOrgSyncConfig }>(
"/api/v1/github-org-sync-config"
);
return data.githubOrgSyncConfig;
}
})
};
@@ -0,0 +1,20 @@
export type TGithubOrgSyncConfig = {
id: string;
orgId: string;
githubAccessToken: string;
githubOrgName: string;
createdAt: string;
isActive?: boolean;
};
export interface TCreateGithubOrgSyncDTO {
githubOrgName: string;
githubOrgAccessToken?: string;
isActive?: boolean;
}
export interface TUpdateGithubOrgSyncDTO {
githubOrgName?: string;
githubOrgAccessToken?: string;
isActive?: boolean;
}
+1
View File
@@ -12,6 +12,7 @@ export * from "./certificateTemplates";
export * from "./dynamicSecret";
export * from "./dynamicSecretLease";
export * from "./gateways";
export * from "./githubOrgSyncConfig";
export * from "./groups";
export * from "./identities";
export * from "./identityProjectAdditionalPrivilege";
@@ -12,6 +12,7 @@ export type SubscriptionPlan = {
customAlerts: boolean;
customRateLimits: boolean;
pitRecovery: boolean;
githubOrgSync: boolean;
ipAllowlisting: boolean;
rbac: boolean;
secretVersioning: boolean;