mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 01:29:38 +00:00
feat(infisical-pg): completed audit log moved ee routes to normal routing pattern
This commit is contained in:
@@ -18,7 +18,7 @@ export const useCreateProjectRole = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ projectId, permissions, ...dto }: TCreateProjectRoleDTO) =>
|
||||
apiRequest.post(`/api/ee/v1/workspace/${projectId}/roles`, {
|
||||
apiRequest.post(`/api/v1/workspace/${projectId}/roles`, {
|
||||
...dto,
|
||||
permissions: permissions.length ? packRules(permissions) : []
|
||||
}),
|
||||
@@ -33,7 +33,7 @@ export const useUpdateProjectRole = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ id, projectId, permissions, ...dto }: TUpdateProjectRoleDTO) =>
|
||||
apiRequest.patch(`/api/ee/v1/workspace/${projectId}/roles/${id}`, {
|
||||
apiRequest.patch(`/api/v1/workspace/${projectId}/roles/${id}`, {
|
||||
...dto,
|
||||
permissions: permissions?.length ? packRules(permissions) : []
|
||||
}),
|
||||
@@ -48,7 +48,7 @@ export const useDeleteProjectRole = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ projectId, id }: TDeleteProjectRoleDTO) =>
|
||||
apiRequest.delete(`/api/ee/v1/workspace/${projectId}/roles/${id}`, {
|
||||
apiRequest.delete(`/api/v1/workspace/${projectId}/roles/${id}`, {
|
||||
data: { projectId }
|
||||
}),
|
||||
onSuccess: (_, { projectId }) => {
|
||||
@@ -62,7 +62,7 @@ export const useCreateOrgRole = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ orgId, permissions, ...dto }: TCreateOrgRoleDTO) =>
|
||||
apiRequest.post(`/api/ee/v1/organization/${orgId}/roles`, {
|
||||
apiRequest.post(`/api/v1/organization/${orgId}/roles`, {
|
||||
...dto,
|
||||
permissions: permissions.length ? packRules(permissions) : []
|
||||
}),
|
||||
@@ -77,7 +77,7 @@ export const useUpdateOrgRole = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ id, orgId, permissions, ...dto }: TUpdateOrgRoleDTO) =>
|
||||
apiRequest.patch(`/api/ee/v1/organization/${orgId}/roles/${id}`, {
|
||||
apiRequest.patch(`/api/v1/organization/${orgId}/roles/${id}`, {
|
||||
...dto,
|
||||
permissions: permissions?.length ? packRules(permissions) : []
|
||||
}),
|
||||
@@ -92,7 +92,7 @@ export const useDeleteOrgRole = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ orgId, id }: TDeleteOrgRoleDTO) =>
|
||||
apiRequest.delete(`/api/ee/v1/organization/${orgId}/roles/${id}`, {
|
||||
apiRequest.delete(`/api/v1/organization/${orgId}/roles/${id}`, {
|
||||
data: { orgId }
|
||||
}),
|
||||
onSuccess: (_, { orgId }) => {
|
||||
|
||||
@@ -48,7 +48,7 @@ export const roleQueryKeys = {
|
||||
const getProjectRoles = async (projectId: string) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
data: { roles: Array<Omit<TProjectRole, "permissions"> & { permissions: unknown }> };
|
||||
}>(`/api/ee/v1/workspace/${projectId}/roles`);
|
||||
}>(`/api/v1/workspace/${projectId}/roles`);
|
||||
return data.data.roles.map(({ permissions, ...el }) => ({
|
||||
...el,
|
||||
permissions: unpackRules(permissions as PackRule<TProjectPermission>[])
|
||||
@@ -65,7 +65,7 @@ export const useGetProjectRoles = (projectId: string) =>
|
||||
const getOrgRoles = async (orgId: string) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
data: { roles: Array<Omit<TOrgRole, "permissions"> & { permissions: unknown }> };
|
||||
}>(`/api/ee/v1/organization/${orgId}/roles`);
|
||||
}>(`/api/v1/organization/${orgId}/roles`);
|
||||
return data.data.roles.map(({ permissions, ...el }) => ({
|
||||
...el,
|
||||
permissions: unpackRules(permissions as PackRule<TPermission>[])
|
||||
@@ -85,7 +85,7 @@ const getUserOrgPermissions = async ({ orgId }: TGetUserOrgPermissionsDTO) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
|
||||
membership: OrgUser;
|
||||
}>(`/api/ee/v1/organization/${orgId}/permissions`);
|
||||
}>(`/api/v1/organization/${orgId}/permissions`);
|
||||
|
||||
return data;
|
||||
};
|
||||
@@ -105,7 +105,7 @@ export const useGetUserOrgPermissions = ({ orgId }: TGetUserOrgPermissionsDTO) =
|
||||
const getUserProjectPermissions = async ({ workspaceId }: TGetUserProjectPermissionDTO) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
data: { permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[] };
|
||||
}>(`/api/ee/v1/workspace/${workspaceId}/permissions`, {});
|
||||
}>(`/api/v1/workspace/${workspaceId}/permissions`, {});
|
||||
|
||||
return data.data.permissions;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ export const useCreateSecretApprovalPolicy = () => {
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretPolicyDTO>({
|
||||
mutationFn: async ({ environment, workspaceId, approvals, approvers, secretPath, name }) => {
|
||||
const { data } = await apiRequest.post("/api/ee/v1/secret-approvals", {
|
||||
const { data } = await apiRequest.post("/api/v1/secret-approvals", {
|
||||
environment,
|
||||
workspaceId,
|
||||
approvals,
|
||||
@@ -31,7 +31,7 @@ export const useUpdateSecretApprovalPolicy = () => {
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretPolicyDTO>({
|
||||
mutationFn: async ({ id, approvers, approvals, secretPath, name }) => {
|
||||
const { data } = await apiRequest.patch(`/api/ee/v1/secret-approvals/${id}`, {
|
||||
const { data } = await apiRequest.patch(`/api/v1/secret-approvals/${id}`, {
|
||||
approvals,
|
||||
approvers,
|
||||
secretPath,
|
||||
@@ -50,7 +50,7 @@ export const useDeleteSecretApprovalPolicy = () => {
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretPolicyDTO>({
|
||||
mutationFn: async ({ id }) => {
|
||||
const { data } = await apiRequest.delete(`/api/ee/v1/secret-approvals/${id}`);
|
||||
const { data } = await apiRequest.delete(`/api/v1/secret-approvals/${id}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
|
||||
@@ -19,7 +19,7 @@ export const secretApprovalKeys = {
|
||||
|
||||
const fetchApprovalPolicies = async (workspaceId: string) => {
|
||||
const { data } = await apiRequest.get<{ approvals: TSecretApprovalPolicy[] }>(
|
||||
"/api/ee/v1/secret-approvals",
|
||||
"/api/v1/secret-approvals",
|
||||
{ params: { workspaceId } }
|
||||
);
|
||||
return data.approvals;
|
||||
@@ -49,7 +49,7 @@ const fetchApprovalPolicyOfABoard = async (
|
||||
secretPath: string
|
||||
) => {
|
||||
const { data } = await apiRequest.get<{ policy: TSecretApprovalPolicy }>(
|
||||
"/api/ee/v1/secret-approvals/board",
|
||||
"/api/v1/secret-approvals/board",
|
||||
{ params: { workspaceId, environment, secretPath } }
|
||||
);
|
||||
return data.policy || "";
|
||||
|
||||
@@ -14,7 +14,7 @@ export const useUpdateSecretApprovalReviewStatus = () => {
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretApprovalReviewStatusDTO>({
|
||||
mutationFn: async ({ id, status }) => {
|
||||
const { data } = await apiRequest.post(`/api/ee/v1/secret-approval-requests/${id}/review`, {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/review`, {
|
||||
status
|
||||
});
|
||||
return data;
|
||||
@@ -30,7 +30,7 @@ export const useUpdateSecretApprovalRequestStatus = () => {
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretApprovalRequestStatusDTO>({
|
||||
mutationFn: async ({ id, status }) => {
|
||||
const { data } = await apiRequest.post(`/api/ee/v1/secret-approval-requests/${id}/status`, {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/status`, {
|
||||
status
|
||||
});
|
||||
return data;
|
||||
@@ -47,7 +47,7 @@ export const usePerformSecretApprovalRequestMerge = () => {
|
||||
|
||||
return useMutation<{}, {}, TPerformSecretApprovalRequestMerge>({
|
||||
mutationFn: async ({ id }) => {
|
||||
const { data } = await apiRequest.post(`/api/ee/v1/secret-approval-requests/${id}/merge`);
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/merge`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { id, workspaceId }) => {
|
||||
|
||||
@@ -96,7 +96,7 @@ const fetchSecretApprovalRequestList = async ({
|
||||
offset
|
||||
}: TGetSecretApprovalRequestList) => {
|
||||
const { data } = await apiRequest.get<{ approvals: TSecretApprovalRequest[] }>(
|
||||
"/api/ee/v1/secret-approval-requests",
|
||||
"/api/v1/secret-approval-requests",
|
||||
{
|
||||
params: {
|
||||
workspaceId,
|
||||
@@ -158,7 +158,7 @@ const fetchSecretApprovalRequestDetails = async ({
|
||||
id
|
||||
}: Omit<TGetSecretApprovalRequestDetails, "decryptKey">) => {
|
||||
const { data } = await apiRequest.get<{ approval: TSecretApprovalRequest }>(
|
||||
`/api/ee/v1/secret-approval-requests/${id}`
|
||||
`/api/v1/secret-approval-requests/${id}`
|
||||
);
|
||||
|
||||
return data.approval;
|
||||
@@ -197,7 +197,7 @@ export const useGetSecretApprovalRequestDetails = ({
|
||||
|
||||
const fetchSecretApprovalRequestCount = async ({ workspaceId }: TGetSecretApprovalRequestCount) => {
|
||||
const { data } = await apiRequest.get<{ approvals: TSecretApprovalRequestCount }>(
|
||||
"/api/ee/v1/secret-approval-requests/count",
|
||||
"/api/v1/secret-approval-requests/count",
|
||||
{ params: { workspaceId } }
|
||||
);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export const useCreateSecretRotation = () => {
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretRotationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/ee/v1/secret-rotations", dto);
|
||||
const { data } = await apiRequest.post("/api/v1/secret-rotations", dto);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
@@ -28,7 +28,7 @@ export const useDeleteSecretRotation = () => {
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretRotationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete(`/api/ee/v1/secret-rotations/${dto.id}`);
|
||||
const { data } = await apiRequest.delete(`/api/v1/secret-rotations/${dto.id}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
@@ -42,7 +42,7 @@ export const useRestartSecretRotation = () => {
|
||||
|
||||
return useMutation<{}, {}, TRestartSecretRotationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/ee/v1/secret-rotations/restart", { id: dto.id });
|
||||
const { data } = await apiRequest.post("/api/v1/secret-rotations/restart", { id: dto.id });
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
|
||||
@@ -25,7 +25,7 @@ export const secretRotationKeys = {
|
||||
|
||||
const fetchSecretRotationProviders = async ({ workspaceId }: TGetSecretRotationProviders) => {
|
||||
const { data } = await apiRequest.get<TSecretRotationProviderList>(
|
||||
`/api/ee/v1/secret-rotation-providers/${workspaceId}`
|
||||
`/api/v1/secret-rotation-providers/${workspaceId}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
@@ -55,7 +55,7 @@ const fetchSecretRotations = async ({
|
||||
workspaceId
|
||||
}: Omit<TGetSecretRotationList, "decryptFileKey">) => {
|
||||
const { data } = await apiRequest.get<{ secretRotations: TSecretRotation[] }>(
|
||||
"/api/ee/v1/secret-rotations",
|
||||
"/api/v1/secret-rotations",
|
||||
{ params: { workspaceId } }
|
||||
);
|
||||
return data.secretRotations;
|
||||
|
||||
@@ -35,7 +35,7 @@ const fetchWorkspaceSnaphots = async ({
|
||||
offset = 0
|
||||
}: TGetSecretSnapshotsDTO & { offset: number }) => {
|
||||
const res = await apiRequest.get<{ secretSnapshots: TSecretSnapshot[] }>(
|
||||
`/api/ee/v1/workspace/${workspaceId}/secret-snapshots`,
|
||||
`/api/v1/workspace/${workspaceId}/secret-snapshots`,
|
||||
{
|
||||
params: {
|
||||
limit,
|
||||
@@ -60,7 +60,7 @@ export const useGetWorkspaceSnapshotList = (dto: TGetSecretSnapshotsDTO & { isPa
|
||||
|
||||
const fetchSnapshotEncSecrets = async (snapshotId: string) => {
|
||||
const res = await apiRequest.get<{ secretSnapshot: TSnapshotData }>(
|
||||
`/api/ee/v1/secret-snapshot/${snapshotId}`
|
||||
`/api/v1/secret-snapshot/${snapshotId}`
|
||||
);
|
||||
return res.data.secretSnapshot;
|
||||
};
|
||||
@@ -142,7 +142,7 @@ const fetchWorkspaceSecretSnaphotCount = async (
|
||||
directory = "/"
|
||||
) => {
|
||||
const res = await apiRequest.get<{ count: number }>(
|
||||
`/api/ee/v1/workspace/${workspaceId}/secret-snapshots/count`,
|
||||
`/api/v1/workspace/${workspaceId}/secret-snapshots/count`,
|
||||
{
|
||||
params: {
|
||||
environment,
|
||||
@@ -170,7 +170,7 @@ export const usePerformSecretRollback = () => {
|
||||
|
||||
return useMutation<{}, {}, TSecretRollbackDTO>({
|
||||
mutationFn: async ({ snapshotId }) => {
|
||||
const { data } = await apiRequest.post(`/api/ee/v1/secret-snapshot/${snapshotId}/rollback`);
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-snapshot/${snapshotId}/rollback`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, directory }) => {
|
||||
|
||||
@@ -3,22 +3,20 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
const ssoConfigKeys = {
|
||||
getSSOConfig: (orgId: string) => [{ orgId }, "organization-saml-sso"] as const,
|
||||
}
|
||||
getSSOConfig: (orgId: string) => [{ orgId }, "organization-saml-sso"] as const
|
||||
};
|
||||
|
||||
export const useGetSSOConfig = (organizationId: string) => {
|
||||
return useQuery({
|
||||
queryKey: ssoConfigKeys.getSSOConfig(organizationId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get(
|
||||
`/api/v1/sso/config?organizationId=${organizationId}`
|
||||
);
|
||||
const { data } = await apiRequest.get(`/api/v1/sso/config?organizationId=${organizationId}`);
|
||||
|
||||
return data;
|
||||
},
|
||||
enabled: true
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const useCreateSSOConfig = () => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -38,18 +36,15 @@ export const useCreateSSOConfig = () => {
|
||||
issuer: string;
|
||||
cert: string;
|
||||
}) => {
|
||||
const { data } = await apiRequest.post(
|
||||
"/api/v1/sso/config",
|
||||
{
|
||||
organizationId,
|
||||
authProvider,
|
||||
isActive,
|
||||
entryPoint,
|
||||
issuer,
|
||||
cert
|
||||
}
|
||||
);
|
||||
|
||||
const { data } = await apiRequest.post("/api/v1/sso/config", {
|
||||
organizationId,
|
||||
authProvider,
|
||||
isActive,
|
||||
entryPoint,
|
||||
issuer,
|
||||
cert
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
@@ -76,22 +71,19 @@ export const useUpdateSSOConfig = () => {
|
||||
issuer?: string;
|
||||
cert?: string;
|
||||
}) => {
|
||||
const { data } = await apiRequest.patch(
|
||||
"/api/v1/sso/config",
|
||||
{
|
||||
organizationId,
|
||||
...(authProvider !== undefined ? { authProvider } : {}),
|
||||
...(isActive !== undefined ? { isActive } : {}),
|
||||
...(entryPoint !== undefined ? { entryPoint } : {}),
|
||||
...(issuer !== undefined ? { issuer } : {}),
|
||||
...(cert !== undefined ? { cert } : {})
|
||||
}
|
||||
);
|
||||
|
||||
const { data } = await apiRequest.patch("/api/v1/sso/config", {
|
||||
organizationId,
|
||||
...(authProvider !== undefined ? { authProvider } : {}),
|
||||
...(isActive !== undefined ? { isActive } : {}),
|
||||
...(entryPoint !== undefined ? { entryPoint } : {}),
|
||||
...(issuer !== undefined ? { issuer } : {}),
|
||||
...(cert !== undefined ? { cert } : {})
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(ssoConfigKeys.getSSOConfig(dto.organizationId));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user