mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 10:29:52 +00:00
feat(ui): updated api changes made
This commit is contained in:
@@ -21,8 +21,8 @@ export const useCreateDynamicSecret = () => {
|
||||
);
|
||||
return data.dynamicSecret;
|
||||
},
|
||||
onSuccess: (_, { path, environment, projectSlug }) => {
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -33,13 +33,13 @@ export const useUpdateDynamicSecret = () => {
|
||||
return useMutation<{}, {}, TUpdateDynamicSecretDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch<{ dynamicSecret: TDynamicSecret }>(
|
||||
`/api/v1/dynamic-secrets/${dto.slug}`,
|
||||
`/api/v1/dynamic-secrets/${dto.name}`,
|
||||
dto
|
||||
);
|
||||
return data.dynamicSecret;
|
||||
},
|
||||
onSuccess: (_, { path, environment, projectSlug }) => {
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -50,13 +50,13 @@ export const useDeleteDynamicSecret = () => {
|
||||
return useMutation<{}, {}, TDeleteDynamicSecretDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete<{ dynamicSecret: TDynamicSecret }>(
|
||||
`/api/v1/dynamic-secrets/${dto.slug}`,
|
||||
`/api/v1/dynamic-secrets/${dto.name}`,
|
||||
{ data: dto }
|
||||
);
|
||||
return data.dynamicSecret;
|
||||
},
|
||||
onSuccess: (_, { path, environment, projectSlug }) => {
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environment }));
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -7,25 +7,25 @@ import { TDetailsDynamicSecretDTO, TDynamicSecret, TListDynamicSecretDTO } from
|
||||
export const dynamicSecretKeys = {
|
||||
list: ({
|
||||
projectSlug,
|
||||
environment,
|
||||
environmentSlug,
|
||||
path
|
||||
}: 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
|
||||
}: Pick<TListDynamicSecretDTO, "path" | "environmentSlug" | "projectSlug">) =>
|
||||
[{ projectSlug, environmentSlug, path }, "dynamic-secrets"] as const,
|
||||
details: ({ path, environmentSlug, projectSlug, name }: TDetailsDynamicSecretDTO) =>
|
||||
[{ projectSlug, path, environmentSlug, name }, "dynamic-secret-details"] as const
|
||||
};
|
||||
|
||||
export const useGetDynamicSecrets = ({ projectSlug, environment, path }: TListDynamicSecretDTO) => {
|
||||
export const useGetDynamicSecrets = ({ projectSlug, environmentSlug, path }: TListDynamicSecretDTO) => {
|
||||
return useQuery({
|
||||
queryKey: dynamicSecretKeys.list({ path, environment, projectSlug }),
|
||||
enabled: Boolean(projectSlug && environment && path),
|
||||
queryKey: dynamicSecretKeys.list({ path, environmentSlug, projectSlug }),
|
||||
enabled: Boolean(projectSlug && environmentSlug && path),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ dynamicSecrets: TDynamicSecret[] }>(
|
||||
"/api/v1/dynamic-secrets",
|
||||
{
|
||||
params: {
|
||||
projectSlug,
|
||||
environment,
|
||||
environmentSlug,
|
||||
path
|
||||
}
|
||||
}
|
||||
@@ -38,20 +38,20 @@ export const useGetDynamicSecrets = ({ projectSlug, environment, path }: TListDy
|
||||
|
||||
export const useGetDynamicSecretDetails = ({
|
||||
projectSlug,
|
||||
environment,
|
||||
environmentSlug,
|
||||
path,
|
||||
slug
|
||||
name
|
||||
}: TDetailsDynamicSecretDTO) => {
|
||||
return useQuery({
|
||||
queryKey: dynamicSecretKeys.details({ path, environment, projectSlug, slug }),
|
||||
enabled: Boolean(projectSlug && environment && path && slug),
|
||||
queryKey: dynamicSecretKeys.details({ path, environmentSlug, projectSlug, name }),
|
||||
enabled: Boolean(projectSlug && environmentSlug && path && name),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{
|
||||
dynamicSecret: TDynamicSecret & { inputs: unknown };
|
||||
}>(`/api/v1/dynamic-secrets/${slug}`, {
|
||||
}>(`/api/v1/dynamic-secrets/${name}`, {
|
||||
params: {
|
||||
projectSlug,
|
||||
environment,
|
||||
environmentSlug,
|
||||
path
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ export enum DynamicSecretStatus {
|
||||
// TODO(akhilmhdh): When we switch to monorepo all the server api ts will be in a shared repo
|
||||
export type TDynamicSecret = {
|
||||
id: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
type: DynamicSecretProviders;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -45,17 +45,17 @@ export type TCreateDynamicSecretDTO = {
|
||||
defaultTTL: string;
|
||||
maxTTL?: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
slug: string;
|
||||
environmentSlug: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type TUpdateDynamicSecretDTO = {
|
||||
slug: string;
|
||||
name: string;
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
environmentSlug: string;
|
||||
data: {
|
||||
newSlug?: string;
|
||||
newName?: string;
|
||||
defaultTTL?: string;
|
||||
maxTTL?: string | null;
|
||||
inputs?: unknown;
|
||||
@@ -65,20 +65,20 @@ export type TUpdateDynamicSecretDTO = {
|
||||
export type TListDynamicSecretDTO = {
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
environmentSlug: string;
|
||||
};
|
||||
|
||||
export type TDeleteDynamicSecretDTO = {
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
slug: string;
|
||||
environmentSlug: string;
|
||||
name: string;
|
||||
isForced?: boolean;
|
||||
};
|
||||
|
||||
export type TDetailsDynamicSecretDTO = {
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
slug: string;
|
||||
environmentSlug: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
@@ -25,9 +25,9 @@ export const useCreateDynamicSecretLease = () => {
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { path, environment, projectSlug, slug }) => {
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -44,9 +44,9 @@ export const useRenewDynamicSecretLease = () => {
|
||||
);
|
||||
return data.lease;
|
||||
},
|
||||
onSuccess: (_, { path, environment, projectSlug, slug }) => {
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -63,9 +63,9 @@ export const useRevokeDynamicSecretLease = () => {
|
||||
);
|
||||
return data.lease;
|
||||
},
|
||||
onSuccess: (_, { path, environment, projectSlug, slug }) => {
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environment, slug })
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,27 +5,27 @@ import { apiRequest } from "@app/config/request";
|
||||
import { TDynamicSecretLease, TListDynamicSecretLeaseDTO } from "./types";
|
||||
|
||||
export const dynamicSecretLeaseKeys = {
|
||||
list: ({ projectSlug, environment, path, slug }: TListDynamicSecretLeaseDTO) =>
|
||||
[{ projectSlug, environment, path, slug }, "dynamic-secret-leases"] as const
|
||||
list: ({ projectSlug, environmentSlug, path, dynamicSecretName }: TListDynamicSecretLeaseDTO) =>
|
||||
[{ projectSlug, environmentSlug, path, dynamicSecretName }, "dynamic-secret-leases"] as const
|
||||
};
|
||||
|
||||
export const useGetDynamicSecretLeases = ({
|
||||
projectSlug,
|
||||
environment,
|
||||
environmentSlug,
|
||||
path,
|
||||
slug,
|
||||
dynamicSecretName,
|
||||
enabled = true
|
||||
}: TListDynamicSecretLeaseDTO) => {
|
||||
return useQuery({
|
||||
queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectSlug, slug }),
|
||||
enabled: Boolean(projectSlug && environment && path && slug && enabled),
|
||||
queryKey: dynamicSecretLeaseKeys.list({ path, environmentSlug, projectSlug, dynamicSecretName }),
|
||||
enabled: Boolean(projectSlug && environmentSlug && path && dynamicSecretName && enabled),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>(
|
||||
`/api/v1/dynamic-secrets/${slug}/leases`,
|
||||
`/api/v1/dynamic-secrets/${dynamicSecretName}/leases`,
|
||||
{
|
||||
params: {
|
||||
projectSlug,
|
||||
environment,
|
||||
environmentSlug,
|
||||
path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,35 +14,35 @@ export type TDynamicSecretLease = {
|
||||
};
|
||||
|
||||
export type TCreateDynamicSecretLeaseDTO = {
|
||||
slug: string;
|
||||
dynamicSecretName: string;
|
||||
projectSlug: string;
|
||||
ttl?: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
environmentSlug: string;
|
||||
};
|
||||
|
||||
export type TRenewDynamicSecretLeaseDTO = {
|
||||
leaseId: string;
|
||||
slug: string;
|
||||
dynamicSecretName: string;
|
||||
ttl?: string;
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
environmentSlug: string;
|
||||
};
|
||||
|
||||
export type TListDynamicSecretLeaseDTO = {
|
||||
slug: string;
|
||||
dynamicSecretName: string;
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
environmentSlug: string;
|
||||
enabled?: boolean;
|
||||
};
|
||||
|
||||
export type TRevokeDynamicSecretLeaseDTO = {
|
||||
leaseId: string;
|
||||
slug: string;
|
||||
dynamicSecretName: string;
|
||||
projectSlug: string;
|
||||
path: string;
|
||||
environment: string;
|
||||
environmentSlug: string;
|
||||
isForced?: boolean;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ export type SubscriptionPlan = {
|
||||
membersUsed: number;
|
||||
memberLimit: number;
|
||||
auditLogs: boolean;
|
||||
dynamicSecret: boolean;
|
||||
auditLogsRetentionDays: number;
|
||||
customAlerts: boolean;
|
||||
customRateLimits: boolean;
|
||||
@@ -21,14 +22,14 @@ export type SubscriptionPlan = {
|
||||
scim: boolean;
|
||||
ldap: boolean;
|
||||
status:
|
||||
| "incomplete"
|
||||
| "incomplete_expired"
|
||||
| "trialing"
|
||||
| "active"
|
||||
| "past_due"
|
||||
| "canceled"
|
||||
| "unpaid"
|
||||
| null;
|
||||
| "incomplete"
|
||||
| "incomplete_expired"
|
||||
| "trialing"
|
||||
| "active"
|
||||
| "past_due"
|
||||
| "canceled"
|
||||
| "unpaid"
|
||||
| null;
|
||||
trial_end: number | null;
|
||||
has_used_trial: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user