feat: gcp secret sync management

This commit is contained in:
Sheen Capadngan
2025-01-25 03:01:10 +08:00
parent 58f51411c0
commit 753c28a2d3
34 changed files with 467 additions and 22 deletions
@@ -0,0 +1,37 @@
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { appConnectionKeys } from "../queries";
import { TGcpProject } from "./types";
const gcpConnectionKeys = {
all: [...appConnectionKeys.all, "gcp"] as const,
listProjects: (connectionId: string) =>
[...gcpConnectionKeys.all, "projects", connectionId] as const
};
export const useGcpConnectionListProjects = (
connectionId: string,
options?: Omit<
UseQueryOptions<
TGcpProject[],
unknown,
TGcpProject[],
ReturnType<typeof gcpConnectionKeys.listProjects>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: gcpConnectionKeys.listProjects(connectionId),
queryFn: async () => {
const { data } = await apiRequest.get<TGcpProject[]>(
`/api/v1/app-connections/gcp/${connectionId}/secret-manager-projects`
);
return data;
},
...options
});
};
@@ -0,0 +1,4 @@
export type TGcpProject = {
id: string;
name: string;
};