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;
@@ -25,9 +25,9 @@ export const useCreateDynamicSecretLease = () => {
);
return data;
},
onSuccess: (_, { path, environment, projectId, slug }) => {
onSuccess: (_, { path, environment, projectSlug, slug }) => {
queryClient.invalidateQueries(
dynamicSecretLeaseKeys.list({ path, projectId, environment, slug })
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
);
}
});
@@ -44,9 +44,9 @@ export const useRenewDynamicSecretLease = () => {
);
return data.lease;
},
onSuccess: (_, { path, environment, projectId, slug }) => {
onSuccess: (_, { path, environment, projectSlug, slug }) => {
queryClient.invalidateQueries(
dynamicSecretLeaseKeys.list({ path, projectId, environment, slug })
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
);
}
});
@@ -63,9 +63,9 @@ export const useRevokeDynamicSecretLease = () => {
);
return data.lease;
},
onSuccess: (_, { path, environment, projectId, slug }) => {
onSuccess: (_, { path, environment, projectSlug, slug }) => {
queryClient.invalidateQueries(
dynamicSecretLeaseKeys.list({ path, projectId, environment, slug })
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
);
}
});
@@ -5,26 +5,26 @@ import { apiRequest } from "@app/config/request";
import { TDynamicSecretLease, TListDynamicSecretLeaseDTO } from "./types";
export const dynamicSecretLeaseKeys = {
list: ({ projectId, environment, path, slug }: TListDynamicSecretLeaseDTO) =>
[{ projectId, environment, path, slug }, "dynamic-secret-leases"] as const
list: ({ projectSlug, environment, path, slug }: TListDynamicSecretLeaseDTO) =>
[{ projectSlug, environment, path, slug }, "dynamic-secret-leases"] as const
};
export const useGetDynamicSecretLeases = ({
projectId,
projectSlug,
environment,
path,
slug,
enabled = true
}: TListDynamicSecretLeaseDTO) => {
return useQuery({
queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectId, slug }),
enabled: Boolean(projectId && environment && path && slug && enabled),
queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectSlug, slug }),
enabled: Boolean(projectSlug && environment && path && slug && enabled),
queryFn: async () => {
const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>(
`/api/v1/dynamic-secrets/leases/${slug}`,
`/api/v1/dynamic-secrets/${slug}/leases`,
{
params: {
projectId,
projectSlug,
environment,
path
}
@@ -15,7 +15,7 @@ export type TDynamicSecretLease = {
export type TCreateDynamicSecretLeaseDTO = {
slug: string;
projectId: string;
projectSlug: string;
ttl?: string;
path: string;
environment: string;
@@ -25,14 +25,14 @@ export type TRenewDynamicSecretLeaseDTO = {
leaseId: string;
slug: string;
ttl?: string;
projectId: string;
projectSlug: string;
path: string;
environment: string;
};
export type TListDynamicSecretLeaseDTO = {
slug: string;
projectId: string;
projectSlug: string;
path: string;
environment: string;
enabled?: boolean;
@@ -41,7 +41,7 @@ export type TListDynamicSecretLeaseDTO = {
export type TRevokeDynamicSecretLeaseDTO = {
leaseId: string;
slug: string;
projectId: string;
projectSlug: string;
path: string;
environment: string;
};