feat: changed the whole api from projectid to slug

This commit is contained in:
Akhil Mohan
2024-03-22 14:18:12 +05:30
parent 70fe80414d
commit e3e62430ba
28 changed files with 357 additions and 165 deletions
@@ -21,8 +21,8 @@ export const useCreateDynamicSecret = () => {
);
return data.dynamicSecret;
},
onSuccess: (_, { path, environment, projectId }) => {
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectId, environment }));
onSuccess: (_, { path, environment, projectSlug }) => {
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
}
});
};
@@ -38,8 +38,8 @@ export const useUpdateDynamicSecret = () => {
);
return data.dynamicSecret;
},
onSuccess: (_, { path, environment, projectId }) => {
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectId, environment }));
onSuccess: (_, { path, environment, projectSlug }) => {
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
}
});
};
@@ -55,8 +55,8 @@ export const useDeleteDynamicSecret = () => {
);
return data.dynamicSecret;
},
onSuccess: (_, { path, environment, projectId }) => {
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectId, environment }));
onSuccess: (_, { path, environment, projectSlug }) => {
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
}
});
};
+13 -13
View File
@@ -6,25 +6,25 @@ import { TDetailsDynamicSecretDTO, TDynamicSecret, TListDynamicSecretDTO } from
export const dynamicSecretKeys = {
list: ({
projectId,
projectSlug,
environment,
path
}: Pick<TListDynamicSecretDTO, "path" | "environment" | "projectId">) =>
[{ projectId, environment, path }, "dynamic-secrets"] as const,
details: ({ path, environment, projectId, slug }: TDetailsDynamicSecretDTO) =>
[{ projectId, path, environment, slug }, "dynamic-secret-details"] as const
}: Pick<TListDynamicSecretDTO, "path" | "environment" | "projectSlug">) =>
[{ projectSlug, environment, path }, "dynamic-secrets"] as const,
details: ({ path, environment, projectSlug, slug }: TDetailsDynamicSecretDTO) =>
[{ projectSlug, path, environment, slug }, "dynamic-secret-details"] as const
};
export const useGetDynamicSecrets = ({ projectId, environment, path }: TListDynamicSecretDTO) => {
export const useGetDynamicSecrets = ({ projectSlug, environment, path }: TListDynamicSecretDTO) => {
return useQuery({
queryKey: dynamicSecretKeys.list({ path, environment, projectId }),
enabled: Boolean(projectId && environment && path),
queryKey: dynamicSecretKeys.list({ path, environment, projectSlug }),
enabled: Boolean(projectSlug && environment && path),
queryFn: async () => {
const { data } = await apiRequest.get<{ dynamicSecrets: TDynamicSecret[] }>(
"/api/v1/dynamic-secrets",
{
params: {
projectId,
projectSlug,
environment,
path
}
@@ -37,20 +37,20 @@ export const useGetDynamicSecrets = ({ projectId, environment, path }: TListDyna
};
export const useGetDynamicSecretDetails = ({
projectId,
projectSlug,
environment,
path,
slug
}: TDetailsDynamicSecretDTO) => {
return useQuery({
queryKey: dynamicSecretKeys.details({ path, environment, projectId, slug }),
enabled: Boolean(projectId && environment && path && slug),
queryKey: dynamicSecretKeys.details({ path, environment, projectSlug, slug }),
enabled: Boolean(projectSlug && environment && path && slug),
queryFn: async () => {
const { data } = await apiRequest.get<{
dynamicSecret: TDynamicSecret & { inputs: unknown };
}>(`/api/v1/dynamic-secrets/${slug}`, {
params: {
projectId,
projectSlug,
environment,
path
}
@@ -40,7 +40,7 @@ export type TDynamicSecretProvider = {
};
export type TCreateDynamicSecretDTO = {
projectId: string;
projectSlug: string;
provider: TDynamicSecretProvider;
defaultTTL: string;
maxTTL?: string;
@@ -51,7 +51,7 @@ export type TCreateDynamicSecretDTO = {
export type TUpdateDynamicSecretDTO = {
slug: string;
projectId: string;
projectSlug: string;
path: string;
environment: string;
data: {
@@ -63,20 +63,20 @@ export type TUpdateDynamicSecretDTO = {
};
export type TListDynamicSecretDTO = {
projectId: string;
projectSlug: string;
path: string;
environment: string;
};
export type TDeleteDynamicSecretDTO = {
projectId: string;
projectSlug: string;
path: string;
environment: string;
slug: string;
};
export type TDetailsDynamicSecretDTO = {
projectId: string;
projectSlug: string;
path: string;
environment: string;
slug: string;