mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 20:25:43 +00:00
Merge remote-tracking branch 'origin/main' into feat/resource-metadata
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
export const useCreateAccessApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateAccessPolicyDTO>({
|
||||
return useMutation<object, object, TCreateAccessPolicyDTO>({
|
||||
mutationFn: async ({
|
||||
environment,
|
||||
projectSlug,
|
||||
@@ -37,7 +37,9 @@ export const useCreateAccessApprovalPolicy = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalPolicies(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -45,7 +47,7 @@ export const useCreateAccessApprovalPolicy = () => {
|
||||
export const useUpdateAccessApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateAccessPolicyDTO>({
|
||||
return useMutation<object, object, TUpdateAccessPolicyDTO>({
|
||||
mutationFn: async ({ id, approvers, approvals, name, secretPath, enforcementLevel }) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/access-approvals/policies/${id}`, {
|
||||
approvals,
|
||||
@@ -57,7 +59,9 @@ export const useUpdateAccessApprovalPolicy = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalPolicies(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -65,20 +69,22 @@ export const useUpdateAccessApprovalPolicy = () => {
|
||||
export const useDeleteAccessApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretPolicyDTO>({
|
||||
return useMutation<object, object, TDeleteSecretPolicyDTO>({
|
||||
mutationFn: async ({ id }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/access-approvals/policies/${id}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalPolicies(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateAccessRequest = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, TCreateAccessRequestDTO>({
|
||||
return useMutation<object, object, TCreateAccessRequestDTO>({
|
||||
mutationFn: async ({ projectSlug, ...request }) => {
|
||||
const { data } = await apiRequest.post<TAccessApproval>(
|
||||
"/api/v1/access-approvals/requests",
|
||||
@@ -96,7 +102,9 @@ export const useCreateAccessRequest = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalRequestCount(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -104,8 +112,8 @@ export const useCreateAccessRequest = () => {
|
||||
export const useReviewAccessRequest = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<
|
||||
{},
|
||||
{},
|
||||
object,
|
||||
object,
|
||||
{
|
||||
requestId: string;
|
||||
status: "approved" | "rejected";
|
||||
@@ -124,10 +132,12 @@ export const useReviewAccessRequest = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug, envSlug, requestedBy }) => {
|
||||
queryClient.invalidateQueries(
|
||||
accessApprovalKeys.getAccessApprovalRequests(projectSlug, envSlug, requestedBy)
|
||||
);
|
||||
queryClient.invalidateQueries(accessApprovalKeys.getAccessApprovalRequestCount(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalRequests(projectSlug, envSlug, requestedBy)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { PackRule, unpackRules } from "@casl/ability/extra";
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import { TProjectPermission } from "../roles/types";
|
||||
import {
|
||||
@@ -41,15 +42,9 @@ export const useGetAccessPolicyApprovalCount = ({
|
||||
projectSlug,
|
||||
envSlug,
|
||||
options = {}
|
||||
}: TGetAccessPolicyApprovalCountDTO & {
|
||||
options?: UseQueryOptions<
|
||||
number,
|
||||
unknown,
|
||||
number,
|
||||
ReturnType<typeof accessApprovalKeys.getAccessApprovalPolicies>
|
||||
>;
|
||||
}) =>
|
||||
}: TGetAccessPolicyApprovalCountDTO & TReactQueryOptions) =>
|
||||
useQuery({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug),
|
||||
queryFn: () => fetchPolicyApprovalCount({ projectSlug, envSlug }),
|
||||
...options,
|
||||
enabled: Boolean(projectSlug) && (options?.enabled ?? true)
|
||||
@@ -99,14 +94,7 @@ const fetchAccessRequestsCount = async (projectSlug: string) => {
|
||||
export const useGetAccessRequestsCount = ({
|
||||
projectSlug,
|
||||
options = {}
|
||||
}: TGetAccessApprovalRequestsDTO & {
|
||||
options?: UseQueryOptions<
|
||||
TAccessRequestCount,
|
||||
unknown,
|
||||
{ pendingCount: number; finalizedCount: number },
|
||||
ReturnType<typeof accessApprovalKeys.getAccessApprovalRequestCount>
|
||||
>;
|
||||
}) =>
|
||||
}: TGetAccessApprovalRequestsDTO & TReactQueryOptions) =>
|
||||
useQuery({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug),
|
||||
queryFn: () => fetchAccessRequestsCount(projectSlug),
|
||||
@@ -119,14 +107,7 @@ export const useGetAccessApprovalPolicies = ({
|
||||
envSlug,
|
||||
authorProjectMembershipId,
|
||||
options = {}
|
||||
}: TGetAccessApprovalRequestsDTO & {
|
||||
options?: UseQueryOptions<
|
||||
TAccessApprovalPolicy[],
|
||||
unknown,
|
||||
TAccessApprovalPolicy[],
|
||||
ReturnType<typeof accessApprovalKeys.getAccessApprovalPolicies>
|
||||
>;
|
||||
}) =>
|
||||
}: TGetAccessApprovalRequestsDTO & TReactQueryOptions) =>
|
||||
useQuery({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalPolicies(projectSlug),
|
||||
queryFn: () => fetchApprovalPolicies({ projectSlug, envSlug, authorProjectMembershipId }),
|
||||
@@ -139,14 +120,7 @@ export const useGetAccessApprovalRequests = ({
|
||||
envSlug,
|
||||
authorProjectMembershipId,
|
||||
options = {}
|
||||
}: TGetAccessApprovalRequestsDTO & {
|
||||
options?: UseQueryOptions<
|
||||
TAccessApprovalRequest[],
|
||||
unknown,
|
||||
TAccessApprovalRequest[],
|
||||
ReturnType<typeof accessApprovalKeys.getAccessApprovalRequests>
|
||||
>;
|
||||
}) =>
|
||||
}: TGetAccessApprovalRequestsDTO & TReactQueryOptions) =>
|
||||
useQuery({
|
||||
queryKey: accessApprovalKeys.getAccessApprovalRequests(
|
||||
projectSlug,
|
||||
|
||||
@@ -18,7 +18,7 @@ export const useCreateAdminUser = () => {
|
||||
|
||||
return useMutation<
|
||||
{ user: User; token: string; organization: { id: string } },
|
||||
{},
|
||||
object,
|
||||
TCreateAdminUserDTO
|
||||
>({
|
||||
mutationFn: async (opt) => {
|
||||
@@ -26,7 +26,7 @@ export const useCreateAdminUser = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(adminQueryKeys.serverConfig());
|
||||
queryClient.invalidateQueries({ queryKey: adminQueryKeys.serverConfig() });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -36,7 +36,7 @@ export const useUpdateServerConfig = () => {
|
||||
|
||||
return useMutation<
|
||||
TServerConfig,
|
||||
{},
|
||||
object,
|
||||
Partial<TServerConfig & { slackClientId: string; slackClientSecret: string }>
|
||||
>({
|
||||
mutationFn: async (opt) => {
|
||||
@@ -48,8 +48,8 @@ export const useUpdateServerConfig = () => {
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(adminQueryKeys.serverConfig(), data);
|
||||
queryClient.invalidateQueries(adminQueryKeys.serverConfig());
|
||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||
queryClient.invalidateQueries({ queryKey: adminQueryKeys.serverConfig() });
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -72,7 +72,7 @@ export const useAdminDeleteUser = () => {
|
||||
|
||||
export const useUpdateAdminSlackConfig = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<AdminSlackConfig, {}, TUpdateAdminSlackConfigDTO>({
|
||||
return useMutation<AdminSlackConfig, object, TUpdateAdminSlackConfigDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.put<AdminSlackConfig>(
|
||||
"/api/v1/admin/integrations/slack/config",
|
||||
@@ -82,7 +82,7 @@ export const useUpdateAdminSlackConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(adminQueryKeys.getAdminSlackConfig());
|
||||
queryClient.invalidateQueries({ queryKey: adminQueryKeys.getAdminSlackConfig() });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -94,7 +94,7 @@ export const useUpdateServerEncryptionStrategy = () => {
|
||||
await apiRequest.patch("/api/v1/admin/encryption-strategies", { strategy });
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(adminQueryKeys.getServerEncryptionStrategies());
|
||||
queryClient.invalidateQueries({ queryKey: adminQueryKeys.getServerEncryptionStrategies() });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ export const adminQueryKeys = {
|
||||
getServerEncryptionStrategies: () => ["server-encryption-strategies"] as const
|
||||
};
|
||||
|
||||
const fetchServerConfig = async () => {
|
||||
export const fetchServerConfig = async () => {
|
||||
const { data } = await apiRequest.get<{ config: TServerConfig }>("/api/v1/admin/config");
|
||||
return data.config;
|
||||
};
|
||||
@@ -48,6 +48,7 @@ export const useGetServerConfig = ({
|
||||
|
||||
export const useAdminGetUsers = (filters: AdminGetUsersFilters) => {
|
||||
return useInfiniteQuery({
|
||||
initialPageParam: 0,
|
||||
queryKey: adminQueryKeys.getUsers(filters),
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const { data } = await apiRequest.get<{ users: User[] }>(
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
|
||||
export const useCreateAPIKeyV2 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<CreateServiceTokenDataV3Res, {}, CreateAPIKeyDataV2DTO>({
|
||||
return useMutation<CreateServiceTokenDataV3Res, object, CreateAPIKeyDataV2DTO>({
|
||||
mutationFn: async ({ name }) => {
|
||||
const { data } = await apiRequest.post("/api/v3/api-key", {
|
||||
name
|
||||
@@ -22,14 +22,14 @@ export const useCreateAPIKeyV2 = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.myAPIKeysV2);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.myAPIKeysV2 });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateAPIKeyV2 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<APIKeyDataV2, {}, UpdateAPIKeyDataV2DTO>({
|
||||
return useMutation<APIKeyDataV2, object, UpdateAPIKeyDataV2DTO>({
|
||||
mutationFn: async ({ apiKeyDataId, name }) => {
|
||||
const {
|
||||
data: { apiKeyData }
|
||||
@@ -39,14 +39,14 @@ export const useUpdateAPIKeyV2 = () => {
|
||||
return apiKeyData;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.myAPIKeysV2);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.myAPIKeysV2 });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteAPIKeyV2 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<APIKeyDataV2, {}, DeleteAPIKeyDataV2DTO>({
|
||||
return useMutation<APIKeyDataV2, object, DeleteAPIKeyDataV2DTO>({
|
||||
mutationFn: async ({ apiKeyDataId }) => {
|
||||
const {
|
||||
data: { apiKeyData }
|
||||
@@ -54,7 +54,7 @@ export const useDeleteAPIKeyV2 = () => {
|
||||
return apiKeyData;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.myAPIKeysV2);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.myAPIKeysV2 });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ export const useCreateAppConnection = () => {
|
||||
|
||||
return data.appConnection;
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries(appConnectionKeys.list())
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: appConnectionKeys.list() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -36,8 +36,8 @@ export const useUpdateAppConnection = () => {
|
||||
return data.appConnection;
|
||||
},
|
||||
onSuccess: (_, { connectionId, app }) => {
|
||||
queryClient.invalidateQueries(appConnectionKeys.list());
|
||||
queryClient.invalidateQueries(appConnectionKeys.byId(app, connectionId));
|
||||
queryClient.invalidateQueries({ queryKey: appConnectionKeys.list() });
|
||||
queryClient.invalidateQueries({ queryKey: appConnectionKeys.byId(app, connectionId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -51,8 +51,8 @@ export const useDeleteAppConnection = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { connectionId, app }) => {
|
||||
queryClient.invalidateQueries(appConnectionKeys.list());
|
||||
queryClient.invalidateQueries(appConnectionKeys.byId(app, connectionId));
|
||||
queryClient.invalidateQueries({ queryKey: appConnectionKeys.list() });
|
||||
queryClient.invalidateQueries({ queryKey: appConnectionKeys.byId(app, connectionId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -49,12 +49,12 @@ export const useAppConnectionOptions = (
|
||||
};
|
||||
|
||||
export const useGetAppConnectionOption = <T extends AppConnection>(app: T) => {
|
||||
const { data: options = [], isLoading } = useAppConnectionOptions();
|
||||
const { data: options = [], isPending } = useAppConnectionOptions();
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
option: (options.find((opt) => opt.app === app) as TAppConnectionOptionMap[T]) ?? {},
|
||||
isLoading
|
||||
isLoading: isPending
|
||||
}),
|
||||
[options, app]
|
||||
);
|
||||
@@ -74,9 +74,8 @@ export const useListAppConnections = (
|
||||
return useQuery({
|
||||
queryKey: appConnectionKeys.list(),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TListAppConnections<TAppConnection>>(
|
||||
"/api/v1/app-connections"
|
||||
);
|
||||
const { data } =
|
||||
await apiRequest.get<TListAppConnections<TAppConnection>>("/api/v1/app-connections");
|
||||
|
||||
return data.appConnections;
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
export const useCreateAuditLogStream = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ auditLogStream: TAuditLogStream }, {}, TCreateAuditLogStreamDTO>({
|
||||
return useMutation<{ auditLogStream: TAuditLogStream }, object, TCreateAuditLogStreamDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post<{ auditLogStream: TAuditLogStream }>(
|
||||
"/api/v1/audit-log-streams",
|
||||
@@ -22,7 +22,7 @@ export const useCreateAuditLogStream = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(auditLogStreamKeys.list(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: auditLogStreamKeys.list(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -30,7 +30,7 @@ export const useCreateAuditLogStream = () => {
|
||||
export const useUpdateAuditLogStream = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ auditLogStream: TAuditLogStream }, {}, TUpdateAuditLogStreamDTO>({
|
||||
return useMutation<{ auditLogStream: TAuditLogStream }, object, TUpdateAuditLogStreamDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch<{ auditLogStream: TAuditLogStream }>(
|
||||
`/api/v1/audit-log-streams/${dto.id}`,
|
||||
@@ -39,7 +39,7 @@ export const useUpdateAuditLogStream = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(auditLogStreamKeys.list(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: auditLogStreamKeys.list(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -47,7 +47,7 @@ export const useUpdateAuditLogStream = () => {
|
||||
export const useDeleteAuditLogStream = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ auditLogStream: TAuditLogStream }, {}, TDeleteAuditLogStreamDTO>({
|
||||
return useMutation<{ auditLogStream: TAuditLogStream }, object, TDeleteAuditLogStreamDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete<{ auditLogStream: TAuditLogStream }>(
|
||||
`/api/v1/audit-log-streams/${dto.id}`
|
||||
@@ -55,7 +55,7 @@ export const useDeleteAuditLogStream = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(auditLogStreamKeys.list(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: auditLogStreamKeys.list(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5,36 +5,36 @@ import { apiRequest } from "@app/config/request";
|
||||
import { TAuditLogStream } from "./types";
|
||||
|
||||
export const auditLogStreamKeys = {
|
||||
list: (orgId: string) => ["audit-log-stream", { orgId }],
|
||||
getById: (id: string) => ["audit-log-stream-details", { id }]
|
||||
list: (orgId: string) => ["audit-log-stream", { orgId }],
|
||||
getById: (id: string) => ["audit-log-stream-details", { id }]
|
||||
};
|
||||
|
||||
const fetchAuditLogStreams = async () => {
|
||||
const { data } = await apiRequest.get<{ auditLogStreams: TAuditLogStream[] }>(
|
||||
"/api/v1/audit-log-streams"
|
||||
);
|
||||
const { data } = await apiRequest.get<{ auditLogStreams: TAuditLogStream[] }>(
|
||||
"/api/v1/audit-log-streams"
|
||||
);
|
||||
|
||||
return data.auditLogStreams;
|
||||
return data.auditLogStreams;
|
||||
};
|
||||
|
||||
export const useGetAuditLogStreams = (orgId: string) =>
|
||||
useQuery({
|
||||
queryKey: auditLogStreamKeys.list(orgId),
|
||||
queryFn: () => fetchAuditLogStreams(),
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
useQuery({
|
||||
queryKey: auditLogStreamKeys.list(orgId),
|
||||
queryFn: () => fetchAuditLogStreams(),
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
|
||||
const fetchAuditLogStreamDetails = async (id: string) => {
|
||||
const { data } = await apiRequest.get<{ auditLogStream: TAuditLogStream }>(
|
||||
`/api/v1/audit-log-streams/${id}`
|
||||
);
|
||||
const { data } = await apiRequest.get<{ auditLogStream: TAuditLogStream }>(
|
||||
`/api/v1/audit-log-streams/${id}`
|
||||
);
|
||||
|
||||
return data.auditLogStream;
|
||||
return data.auditLogStream;
|
||||
};
|
||||
|
||||
export const useGetAuditLogStreamDetails = (id: string) =>
|
||||
useQuery({
|
||||
queryKey: auditLogStreamKeys.getById(id),
|
||||
queryFn: () => fetchAuditLogStreamDetails(id),
|
||||
enabled: Boolean(id)
|
||||
});
|
||||
useQuery({
|
||||
queryKey: auditLogStreamKeys.getById(id),
|
||||
queryFn: () => fetchAuditLogStreamDetails(id),
|
||||
enabled: Boolean(id)
|
||||
});
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useInfiniteQuery, UseInfiniteQueryOptions, useQuery } from "@tanstack/react-query";
|
||||
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import { Actor, AuditLog, TGetAuditLogsFilter } from "./types";
|
||||
|
||||
@@ -16,18 +17,10 @@ export const auditLogKeys = {
|
||||
export const useGetAuditLogs = (
|
||||
filters: TGetAuditLogsFilter,
|
||||
projectId: string | null,
|
||||
options: Omit<
|
||||
UseInfiniteQueryOptions<
|
||||
AuditLog[],
|
||||
unknown,
|
||||
AuditLog[],
|
||||
AuditLog[],
|
||||
ReturnType<typeof auditLogKeys.getAuditLogs>
|
||||
>,
|
||||
"queryFn" | "queryKey" | "getNextPageParam"
|
||||
> = {}
|
||||
options: TReactQueryOptions["options"] = {}
|
||||
) => {
|
||||
return useInfiniteQuery({
|
||||
initialPageParam: 0,
|
||||
queryKey: auditLogKeys.getAuditLogs(projectId, filters),
|
||||
queryFn: async ({ pageParam }) => {
|
||||
try {
|
||||
|
||||
@@ -45,10 +45,9 @@ export interface IdentityActor {
|
||||
metadata: IdentityActorMetadata;
|
||||
}
|
||||
|
||||
export interface PlatformActorMetadata {}
|
||||
export interface PlatformActor {
|
||||
type: ActorType.PLATFORM;
|
||||
metadata: PlatformActorMetadata;
|
||||
metadata: object;
|
||||
}
|
||||
|
||||
export type Actor = UserActor | ServiceActor | IdentityActor | PlatformActor;
|
||||
|
||||
@@ -2,9 +2,9 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { setAuthToken } from "@app/reactQuery";
|
||||
|
||||
import { organizationKeys } from "../organization/queries";
|
||||
import { setAuthToken } from "../reactQuery";
|
||||
import { workspaceKeys } from "../workspace";
|
||||
import {
|
||||
ChangePasswordDTO,
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
VerifySignupInviteDTO
|
||||
} from "./types";
|
||||
|
||||
const authKeys = {
|
||||
export const authKeys = {
|
||||
getAuthToken: ["token"] as const
|
||||
};
|
||||
|
||||
@@ -77,16 +77,11 @@ export const selectOrganization = async (data: {
|
||||
export const useSelectOrganization = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (details: {
|
||||
organizationId: string;
|
||||
userAgent?: UserAgentType;
|
||||
forceSetCredentials?: boolean;
|
||||
}) => {
|
||||
mutationFn: async (details: { organizationId: string; userAgent?: UserAgentType }) => {
|
||||
const data = await selectOrganization(details);
|
||||
|
||||
// If a custom user agent is set, then this session is meant for another consuming application, not the web application.
|
||||
if ((!details.userAgent && !data.isMfaEnabled) || details.forceSetCredentials) {
|
||||
localStorage.setItem("orgData.id", details.organizationId);
|
||||
if (!details.userAgent && !data.isMfaEnabled) {
|
||||
SecurityClient.setToken(data.token);
|
||||
SecurityClient.setProviderAuthToken("");
|
||||
}
|
||||
@@ -94,10 +89,9 @@ export const useSelectOrganization = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries([
|
||||
organizationKeys.getUserOrganizations,
|
||||
workspaceKeys.getAllUserWorkspace
|
||||
]);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [organizationKeys.getUserOrganizations, workspaceKeys.getAllUserWorkspace]
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -153,7 +147,7 @@ export const useCompleteAccountSignup = () => {
|
||||
};
|
||||
|
||||
export const useSendMfaToken = () => {
|
||||
return useMutation<{}, {}, SendMfaTokenDTO>({
|
||||
return useMutation<object, object, SendMfaTokenDTO>({
|
||||
mutationFn: async ({ email }) => {
|
||||
const { data } = await apiRequest.post("/api/v2/auth/mfa/send", { email });
|
||||
return data;
|
||||
@@ -180,7 +174,7 @@ export const verifyMfaToken = async ({
|
||||
};
|
||||
|
||||
export const useVerifyMfaToken = () => {
|
||||
return useMutation<VerifyMfaTokenRes, {}, VerifyMfaTokenDTO>({
|
||||
return useMutation<VerifyMfaTokenRes, object, VerifyMfaTokenDTO>({
|
||||
mutationFn: async ({ email, mfaCode, mfaMethod }) => {
|
||||
return verifyMfaToken({
|
||||
email,
|
||||
@@ -306,17 +300,18 @@ export const useChangePassword = () => {
|
||||
|
||||
// Refresh token is set as cookie when logged in
|
||||
// Using that we fetch the auth bearer token needed for auth calls
|
||||
const fetchAuthToken = async () => {
|
||||
export const fetchAuthToken = async () => {
|
||||
const { data } = await apiRequest.post<GetAuthTokenAPI>("/api/v1/auth/token", undefined, {
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
setAuthToken(data.token);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const useGetAuthToken = () =>
|
||||
useQuery(authKeys.getAuthToken, fetchAuthToken, {
|
||||
onSuccess: (data) => setAuthToken(data.token),
|
||||
useQuery({
|
||||
queryKey: authKeys.getAuthToken,
|
||||
queryFn: fetchAuthToken,
|
||||
retry: 0
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export type GetAuthTokenAPI = {
|
||||
token: string;
|
||||
organizationId?: string;
|
||||
};
|
||||
|
||||
export type SendMfaTokenDTO = {
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useGetWorkspaceBot = (workspaceId: string) =>
|
||||
export const useUpdateBotActiveStatus = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TSetBotActiveStatusDto>({
|
||||
return useMutation<object, object, TSetBotActiveStatusDto>({
|
||||
mutationFn: ({ botId, isActive, botKey }) => {
|
||||
return apiRequest.patch(`/api/v1/bot/${botId}/active`, {
|
||||
isActive,
|
||||
@@ -31,7 +31,7 @@ export const useUpdateBotActiveStatus = () => {
|
||||
});
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(queryKeys.getBot(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.getBot(workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SshCaStatus } from "@app/hooks/api/ssh-ca";
|
||||
import { SshCertTemplateStatus } from "@app/hooks/api/sshCertificateTemplates";
|
||||
|
||||
import { SshCaStatus } from "../sshCa";
|
||||
import { SshCertTemplateStatus } from "../sshCertificateTemplates";
|
||||
import { CaStatus, CaType } from "./enums";
|
||||
|
||||
export const caTypeToNameMap: { [K in CaType]: string } = {
|
||||
|
||||
@@ -8,4 +8,11 @@ export {
|
||||
useSignIntermediate,
|
||||
useUpdateCa
|
||||
} from "./mutations";
|
||||
export { useGetCaById, useGetCaCert, useGetCaCerts, useGetCaCertTemplates,useGetCaCrls, useGetCaCsr } from "./queries";
|
||||
export {
|
||||
useGetCaById,
|
||||
useGetCaCert,
|
||||
useGetCaCerts,
|
||||
useGetCaCertTemplates,
|
||||
useGetCaCrls,
|
||||
useGetCaCsr
|
||||
} from "./queries";
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
|
||||
export const useCreateCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateAuthority, {}, TCreateCaDTO>({
|
||||
return useMutation<TCertificateAuthority, object, TCreateCaDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const {
|
||||
data: { ca }
|
||||
@@ -29,14 +29,14 @@ export const useCreateCa = () => {
|
||||
return ca;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateAuthority, {}, TUpdateCaDTO>({
|
||||
return useMutation<TCertificateAuthority, object, TUpdateCaDTO>({
|
||||
mutationFn: async ({ caId, projectSlug, ...body }) => {
|
||||
const {
|
||||
data: { ca }
|
||||
@@ -44,15 +44,15 @@ export const useUpdateCa = () => {
|
||||
return ca;
|
||||
},
|
||||
onSuccess: ({ id }, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries(caKeys.getCaById(id));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaById(id) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateAuthority, {}, TDeleteCaDTO>({
|
||||
return useMutation<TCertificateAuthority, object, TDeleteCaDTO>({
|
||||
mutationFn: async ({ caId }) => {
|
||||
const {
|
||||
data: { ca }
|
||||
@@ -60,14 +60,14 @@ export const useDeleteCa = () => {
|
||||
return ca;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useSignIntermediate = () => {
|
||||
// TODO: consider renaming
|
||||
return useMutation<TSignIntermediateResponse, {}, TSignIntermediateDTO>({
|
||||
return useMutation<TSignIntermediateResponse, object, TSignIntermediateDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TSignIntermediateResponse>(
|
||||
`/api/v1/pki/ca/${body.caId}/sign-intermediate`,
|
||||
@@ -80,7 +80,7 @@ export const useSignIntermediate = () => {
|
||||
|
||||
export const useImportCaCertificate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TImportCaCertificateResponse, {}, TImportCaCertificateDTO>({
|
||||
return useMutation<TImportCaCertificateResponse, object, TImportCaCertificateDTO>({
|
||||
mutationFn: async ({ caId, ...body }) => {
|
||||
const { data } = await apiRequest.post<TImportCaCertificateResponse>(
|
||||
`/api/v1/pki/ca/${caId}/import-certificate`,
|
||||
@@ -89,9 +89,9 @@ export const useImportCaCertificate = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { caId, projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries(caKeys.getCaCerts(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCert(caId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCerts(caId) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCert(caId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -99,7 +99,7 @@ export const useImportCaCertificate = () => {
|
||||
// consider rename to issue certificate
|
||||
export const useCreateCertificate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCreateCertificateResponse, {}, TCreateCertificateDTO>({
|
||||
return useMutation<TCreateCertificateResponse, object, TCreateCertificateDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TCreateCertificateResponse>(
|
||||
"/api/v1/pki/certificates/issue-certificate",
|
||||
@@ -108,14 +108,16 @@ export const useCreateCertificate = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.forWorkspaceCertificates(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRenewCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TRenewCaResponse, {}, TRenewCaDTO>({
|
||||
return useMutation<TRenewCaResponse, object, TRenewCaDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TRenewCaResponse>(
|
||||
`/api/v1/pki/ca/${body.caId}/renew`,
|
||||
@@ -124,12 +126,12 @@ export const useRenewCa = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { caId, projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries(caKeys.getCaById(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCert(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCerts(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCsr(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCrl(caId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaById(caId) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCert(caId) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCerts(caId) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCsr(caId) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCrl(caId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -104,4 +104,4 @@ export const useGetCaCertTemplates = (caId: string) => {
|
||||
},
|
||||
enabled: Boolean(caId)
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
|
||||
export const useCreateCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateTemplate, {}, TCreateCertificateTemplateDTO>({
|
||||
return useMutation<TCertificateTemplate, object, TCreateCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
const { data: certificateTemplate } = await apiRequest.post<TCertificateTemplate>(
|
||||
"/api/v1/pki/certificate-templates",
|
||||
@@ -25,15 +25,17 @@ export const useCreateCertTemplate = () => {
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: ({ caId }, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCertificateTemplates(projectId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCertTemplates(caId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateTemplate, {}, TUpdateCertificateTemplateDTO>({
|
||||
return useMutation<TCertificateTemplate, object, TUpdateCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
const { data: certificateTemplate } = await apiRequest.patch<TCertificateTemplate>(
|
||||
`/api/v1/pki/certificate-templates/${data.id}`,
|
||||
@@ -43,16 +45,18 @@ export const useUpdateCertTemplate = () => {
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: ({ caId }, { projectId, id }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCertificateTemplates(projectId));
|
||||
queryClient.invalidateQueries(certTemplateKeys.getCertTemplateById(id));
|
||||
queryClient.invalidateQueries(caKeys.getCaCertTemplates(caId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: certTemplateKeys.getCertTemplateById(id) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateTemplate, {}, TDeleteCertificateTemplateDTO>({
|
||||
return useMutation<TCertificateTemplate, object, TDeleteCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
const { data: certificateTemplate } = await apiRequest.delete<TCertificateTemplate>(
|
||||
`/api/v1/pki/certificate-templates/${data.id}`
|
||||
@@ -60,16 +64,18 @@ export const useDeleteCertTemplate = () => {
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: ({ caId }, { projectId, id }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCertificateTemplates(projectId));
|
||||
queryClient.invalidateQueries(certTemplateKeys.getCertTemplateById(id));
|
||||
queryClient.invalidateQueries(caKeys.getCaCertTemplates(caId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: certTemplateKeys.getCertTemplateById(id) });
|
||||
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateEstConfig = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, TCreateEstConfigDTO>({
|
||||
return useMutation<object, object, TCreateEstConfigDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post(
|
||||
`/api/v1/pki/certificate-templates/${body.certificateTemplateId}/est-config`,
|
||||
@@ -78,14 +84,16 @@ export const useCreateEstConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { certificateTemplateId }) => {
|
||||
queryClient.invalidateQueries(certTemplateKeys.getEstConfig(certificateTemplateId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: certTemplateKeys.getEstConfig(certificateTemplateId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateEstConfig = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, TUpdateEstConfigDTO>({
|
||||
return useMutation<object, object, TUpdateEstConfigDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.patch(
|
||||
`/api/v1/pki/certificate-templates/${body.certificateTemplateId}/est-config`,
|
||||
@@ -94,7 +102,9 @@ export const useUpdateEstConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { certificateTemplateId }) => {
|
||||
queryClient.invalidateQueries(certTemplateKeys.getEstConfig(certificateTemplateId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: certTemplateKeys.getEstConfig(certificateTemplateId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import { TCertificate, TDeleteCertDTO, TRevokeCertDTO } from "./types";
|
||||
|
||||
export const useDeleteCert = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificate, {}, TDeleteCertDTO>({
|
||||
return useMutation<TCertificate, object, TDeleteCertDTO>({
|
||||
mutationFn: async ({ serialNumber }) => {
|
||||
const {
|
||||
data: { certificate }
|
||||
@@ -17,14 +17,16 @@ export const useDeleteCert = () => {
|
||||
return certificate;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.forWorkspaceCertificates(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRevokeCert = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificate, {}, TRevokeCertDTO>({
|
||||
return useMutation<TCertificate, object, TRevokeCertDTO>({
|
||||
mutationFn: async ({ serialNumber, revocationReason }) => {
|
||||
const {
|
||||
data: { certificate }
|
||||
@@ -37,7 +39,9 @@ export const useRevokeCert = () => {
|
||||
return certificate;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.forWorkspaceCertificates(projectSlug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ export const useCreateCmek = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(cmekKeys.getCmeksByProjectId({ projectId }));
|
||||
queryClient.invalidateQueries({ queryKey: cmekKeys.getCmeksByProjectId({ projectId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -40,7 +40,7 @@ export const useUpdateCmek = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(cmekKeys.getCmeksByProjectId({ projectId }));
|
||||
queryClient.invalidateQueries({ queryKey: cmekKeys.getCmeksByProjectId({ projectId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -54,7 +54,7 @@ export const useDeleteCmek = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(cmekKeys.getCmeksByProjectId({ projectId }));
|
||||
queryClient.invalidateQueries({ queryKey: cmekKeys.getCmeksByProjectId({ projectId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ export const useGetCmeksByProjectId = (
|
||||
return data;
|
||||
},
|
||||
enabled: Boolean(projectId) && (options?.enabled ?? true),
|
||||
keepPreviousData: true,
|
||||
placeholderData: (previousData) => previousData,
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { useCallback } from "react";
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import {
|
||||
DashboardProjectSecretsByKeys,
|
||||
@@ -175,26 +173,6 @@ export const useGetProjectSecretsOverview = (
|
||||
includeDynamicSecrets,
|
||||
environments
|
||||
}),
|
||||
onError: (error) => {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const { message, requestId } = error.response?.data as {
|
||||
message: string;
|
||||
requestId: string;
|
||||
};
|
||||
createNotification({
|
||||
title: "Error fetching secret details",
|
||||
type: "error",
|
||||
text: message,
|
||||
copyActions: [
|
||||
{
|
||||
value: requestId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${requestId}`
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
},
|
||||
select: useCallback((data: Awaited<ReturnType<typeof fetchProjectSecretsOverview>>) => {
|
||||
const { secrets, ...select } = data;
|
||||
const uniqueSecrets = secrets ? unique(secrets, (i) => i.secretKey) : [];
|
||||
@@ -213,7 +191,7 @@ export const useGetProjectSecretsOverview = (
|
||||
totalUniqueFoldersInPage: uniqueFolders.length
|
||||
};
|
||||
}, []),
|
||||
keepPreviousData: true
|
||||
placeholderData: (previousData) => previousData
|
||||
});
|
||||
};
|
||||
|
||||
@@ -278,26 +256,6 @@ export const useGetProjectSecretsDetails = (
|
||||
includeDynamicSecrets,
|
||||
tags
|
||||
}),
|
||||
onError: (error) => {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const { message, requestId } = error.response?.data as {
|
||||
message: string;
|
||||
requestId: string;
|
||||
};
|
||||
createNotification({
|
||||
title: "Error fetching secret details",
|
||||
type: "error",
|
||||
text: message,
|
||||
copyActions: [
|
||||
{
|
||||
value: requestId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${requestId}`
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
},
|
||||
select: useCallback(
|
||||
(data: Awaited<ReturnType<typeof fetchProjectSecretsDetails>>) => ({
|
||||
...data,
|
||||
@@ -305,7 +263,7 @@ export const useGetProjectSecretsDetails = (
|
||||
}),
|
||||
[]
|
||||
),
|
||||
keepPreviousData: true
|
||||
placeholderData: (previousData) => previousData
|
||||
});
|
||||
};
|
||||
|
||||
@@ -373,26 +331,6 @@ export const useGetProjectSecretsQuickSearch = (
|
||||
environments,
|
||||
tags
|
||||
}),
|
||||
onError: (error) => {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const { message, requestId } = error.response?.data as {
|
||||
message: string;
|
||||
requestId: string;
|
||||
};
|
||||
createNotification({
|
||||
title: "Error fetching secrets deep search",
|
||||
type: "error",
|
||||
text: message,
|
||||
copyActions: [
|
||||
{
|
||||
value: requestId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${requestId}`
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
},
|
||||
select: useCallback((data: Awaited<ReturnType<typeof fetchProjectSecretsQuickSearch>>) => {
|
||||
const { secrets, folders, dynamicSecrets } = data;
|
||||
|
||||
@@ -413,6 +351,6 @@ export const useGetProjectSecretsQuickSearch = (
|
||||
dynamicSecrets: groupedDynamicSecrets
|
||||
};
|
||||
}, []),
|
||||
keepPreviousData: true
|
||||
placeholderData: (previousData) => previousData
|
||||
});
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
export const useCreateDynamicSecret = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateDynamicSecretDTO>({
|
||||
return useMutation<object, object, TCreateDynamicSecretDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post<{ dynamicSecret: TDynamicSecret }>(
|
||||
"/api/v1/dynamic-secrets",
|
||||
@@ -24,8 +24,10 @@ export const useCreateDynamicSecret = () => {
|
||||
},
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||
// TODO: optimize but we currently don't pass projectId
|
||||
queryClient.invalidateQueries(dashboardKeys.all());
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||
queryClient.invalidateQueries({ queryKey: dashboardKeys.all() });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dynamicSecretKeys.list({ path, projectSlug, environmentSlug })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -33,7 +35,7 @@ export const useCreateDynamicSecret = () => {
|
||||
export const useUpdateDynamicSecret = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateDynamicSecretDTO>({
|
||||
return useMutation<object, object, TUpdateDynamicSecretDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch<{ dynamicSecret: TDynamicSecret }>(
|
||||
`/api/v1/dynamic-secrets/${dto.name}`,
|
||||
@@ -43,8 +45,10 @@ export const useUpdateDynamicSecret = () => {
|
||||
},
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||
// TODO: optimize but currently don't pass projectId
|
||||
queryClient.invalidateQueries(dashboardKeys.all());
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||
queryClient.invalidateQueries({ queryKey: dashboardKeys.all() });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dynamicSecretKeys.list({ path, projectSlug, environmentSlug })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -52,7 +56,7 @@ export const useUpdateDynamicSecret = () => {
|
||||
export const useDeleteDynamicSecret = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteDynamicSecretDTO>({
|
||||
return useMutation<object, object, TDeleteDynamicSecretDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete<{ dynamicSecret: TDynamicSecret }>(
|
||||
`/api/v1/dynamic-secrets/${dto.name}`,
|
||||
@@ -62,8 +66,10 @@ export const useDeleteDynamicSecret = () => {
|
||||
},
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug }) => {
|
||||
// TODO: optimize but currently don't pass projectId
|
||||
queryClient.invalidateQueries(dashboardKeys.all());
|
||||
queryClient.invalidateQueries(dynamicSecretKeys.list({ path, projectSlug, environmentSlug }));
|
||||
queryClient.invalidateQueries({ queryKey: dashboardKeys.all() });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dynamicSecretKeys.list({ path, projectSlug, environmentSlug })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -80,12 +80,12 @@ export const useGetDynamicSecretProviderData = ({
|
||||
tenantId: string;
|
||||
applicationId: string;
|
||||
clientSecret: string;
|
||||
enabled: boolean
|
||||
enabled: boolean;
|
||||
}) => {
|
||||
return useQuery({
|
||||
queryKey: ["users"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.post<{id:string, email: string, name:string}[]>(
|
||||
const { data } = await apiRequest.post<{ id: string; email: string; name: string }[]>(
|
||||
"/api/v1/dynamic-secrets/entra-id/users",
|
||||
{
|
||||
tenantId,
|
||||
|
||||
@@ -15,7 +15,7 @@ export const useCreateDynamicSecretLease = () => {
|
||||
|
||||
return useMutation<
|
||||
{ lease: TDynamicSecretLease; data: unknown },
|
||||
{},
|
||||
object,
|
||||
TCreateDynamicSecretLeaseDTO
|
||||
>({
|
||||
mutationFn: async (dto) => {
|
||||
@@ -26,9 +26,14 @@ export const useCreateDynamicSecretLease = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dynamicSecretLeaseKeys.list({
|
||||
path,
|
||||
projectSlug,
|
||||
environmentSlug,
|
||||
dynamicSecretName
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -36,7 +41,7 @@ export const useCreateDynamicSecretLease = () => {
|
||||
export const useRenewDynamicSecretLease = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TRenewDynamicSecretLeaseDTO>({
|
||||
return useMutation<object, object, TRenewDynamicSecretLeaseDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post<{ lease: TDynamicSecretLease }>(
|
||||
`/api/v1/dynamic-secrets/leases/${dto.leaseId}/renew`,
|
||||
@@ -45,9 +50,14 @@ export const useRenewDynamicSecretLease = () => {
|
||||
return data.lease;
|
||||
},
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dynamicSecretLeaseKeys.list({
|
||||
path,
|
||||
projectSlug,
|
||||
environmentSlug,
|
||||
dynamicSecretName
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -55,7 +65,7 @@ export const useRenewDynamicSecretLease = () => {
|
||||
export const useRevokeDynamicSecretLease = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TRevokeDynamicSecretLeaseDTO>({
|
||||
return useMutation<object, object, TRevokeDynamicSecretLeaseDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete<{ lease: TDynamicSecretLease }>(
|
||||
`/api/v1/dynamic-secrets/leases/${dto.leaseId}`,
|
||||
@@ -64,9 +74,14 @@ export const useRevokeDynamicSecretLease = () => {
|
||||
return data.lease;
|
||||
},
|
||||
onSuccess: (_, { path, environmentSlug, projectSlug, dynamicSecretName }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dynamicSecretLeaseKeys.list({ path, projectSlug, environmentSlug, dynamicSecretName })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dynamicSecretLeaseKeys.list({
|
||||
path,
|
||||
projectSlug,
|
||||
environmentSlug,
|
||||
dynamicSecretName
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -17,7 +17,12 @@ export const useGetDynamicSecretLeases = ({
|
||||
enabled = true
|
||||
}: TListDynamicSecretLeaseDTO) => {
|
||||
return useQuery({
|
||||
queryKey: dynamicSecretLeaseKeys.list({ path, environmentSlug, projectSlug, dynamicSecretName }),
|
||||
queryKey: dynamicSecretLeaseKeys.list({
|
||||
path,
|
||||
environmentSlug,
|
||||
projectSlug,
|
||||
dynamicSecretName
|
||||
}),
|
||||
enabled: Boolean(projectSlug && environmentSlug && path && dynamicSecretName && enabled),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>(
|
||||
@@ -35,5 +40,3 @@ export const useGetDynamicSecretLeases = ({
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -46,4 +46,3 @@ export type TRevokeDynamicSecretLeaseDTO = {
|
||||
environmentSlug: string;
|
||||
isForced?: boolean;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export const useUpdateExternalGroupOrgRoleMappings = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(externalGroupOrgRoleMappingKeys.list());
|
||||
queryClient.invalidateQueries({ queryKey: externalGroupOrgRoleMappingKeys.list() });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ export const useCreateGroup = () => {
|
||||
return group;
|
||||
},
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgGroups(organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getOrgGroups(organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -57,8 +57,8 @@ export const useUpdateGroup = () => {
|
||||
return group;
|
||||
},
|
||||
onSuccess: ({ orgId, id: groupId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgGroups(orgId));
|
||||
queryClient.invalidateQueries(groupKeys.getGroupById(groupId));
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getOrgGroups(orgId) });
|
||||
queryClient.invalidateQueries({ queryKey: groupKeys.getGroupById(groupId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -72,8 +72,8 @@ export const useDeleteGroup = () => {
|
||||
return group;
|
||||
},
|
||||
onSuccess: ({ orgId, id: groupId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgGroups(orgId));
|
||||
queryClient.invalidateQueries(groupKeys.getGroupById(groupId));
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getOrgGroups(orgId) });
|
||||
queryClient.invalidateQueries({ queryKey: groupKeys.getGroupById(groupId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -94,7 +94,7 @@ export const useAddUserToGroup = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { slug }) => {
|
||||
queryClient.invalidateQueries(groupKeys.forGroupUserMemberships(slug));
|
||||
queryClient.invalidateQueries({ queryKey: groupKeys.forGroupUserMemberships(slug) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -117,8 +117,8 @@ export const useRemoveUserFromGroup = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { slug, username }) => {
|
||||
queryClient.invalidateQueries(groupKeys.forGroupUserMemberships(slug));
|
||||
queryClient.invalidateQueries(userKeys.listUserGroupMemberships(username));
|
||||
queryClient.invalidateQueries({ queryKey: groupKeys.forGroupUserMemberships(slug) });
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.listUserGroupMemberships(username) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ export const useListGroupUsers = ({
|
||||
filter
|
||||
}),
|
||||
enabled: Boolean(groupSlug),
|
||||
keepPreviousData: true,
|
||||
placeholderData: (previousData) => previousData,
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams({
|
||||
offset: String(offset),
|
||||
|
||||
@@ -55,7 +55,7 @@ import {
|
||||
|
||||
export const useCreateIdentity = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<Identity, {}, CreateIdentityDTO>({
|
||||
return useMutation<Identity, object, CreateIdentityDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const {
|
||||
data: { identity }
|
||||
@@ -63,14 +63,16 @@ export const useCreateIdentity = () => {
|
||||
return identity;
|
||||
},
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentity = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<Identity, {}, UpdateIdentityDTO>({
|
||||
return useMutation<Identity, object, UpdateIdentityDTO>({
|
||||
mutationFn: async ({ identityId, name, role, metadata }) => {
|
||||
const {
|
||||
data: { identity }
|
||||
@@ -83,15 +85,17 @@ export const useUpdateIdentity = () => {
|
||||
return identity;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentity = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<Identity, {}, DeleteIdentityDTO>({
|
||||
return useMutation<Identity, object, DeleteIdentityDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identity }
|
||||
@@ -99,7 +103,9 @@ export const useDeleteIdentity = () => {
|
||||
return identity;
|
||||
},
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -108,7 +114,7 @@ export const useDeleteIdentity = () => {
|
||||
|
||||
export const useAddIdentityUniversalAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityUniversalAuth, {}, AddIdentityUniversalAuthDTO>({
|
||||
return useMutation<IdentityUniversalAuth, object, AddIdentityUniversalAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
clientSecretTrustedIps,
|
||||
@@ -129,16 +135,20 @@ export const useAddIdentityUniversalAuth = () => {
|
||||
return identityUniversalAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityUniversalAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityUniversalAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityUniversalAuth, {}, UpdateIdentityUniversalAuthDTO>({
|
||||
return useMutation<IdentityUniversalAuth, object, UpdateIdentityUniversalAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
clientSecretTrustedIps,
|
||||
@@ -159,16 +169,20 @@ export const useUpdateIdentityUniversalAuth = () => {
|
||||
return identityUniversalAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityUniversalAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityUniversalAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityUniversalAuth, {}, DeleteIdentityUniversalAuthDTO>({
|
||||
return useMutation<IdentityUniversalAuth, object, DeleteIdentityUniversalAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityUniversalAuth }
|
||||
@@ -176,9 +190,13 @@ export const useDeleteIdentityUniversalAuth = () => {
|
||||
return identityUniversalAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityUniversalAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -187,7 +205,7 @@ export const useCreateIdentityUniversalAuthClientSecret = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<
|
||||
CreateIdentityUniversalAuthClientSecretRes,
|
||||
{},
|
||||
object,
|
||||
CreateIdentityUniversalAuthClientSecretDTO
|
||||
>({
|
||||
mutationFn: async ({ identityId, description, ttl, numUsesLimit }) => {
|
||||
@@ -202,16 +220,16 @@ export const useCreateIdentityUniversalAuthClientSecret = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { identityId }) => {
|
||||
queryClient.invalidateQueries(
|
||||
identitiesKeys.getIdentityUniversalAuthClientSecrets(identityId)
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuthClientSecrets(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRevokeIdentityUniversalAuthClientSecret = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<ClientSecretData, {}, DeleteIdentityUniversalAuthClientSecretDTO>({
|
||||
return useMutation<ClientSecretData, object, DeleteIdentityUniversalAuthClientSecretDTO>({
|
||||
mutationFn: async ({ identityId, clientSecretId }) => {
|
||||
const {
|
||||
data: { clientSecretData }
|
||||
@@ -221,16 +239,16 @@ export const useRevokeIdentityUniversalAuthClientSecret = () => {
|
||||
return clientSecretData;
|
||||
},
|
||||
onSuccess: (_, { identityId }) => {
|
||||
queryClient.invalidateQueries(
|
||||
identitiesKeys.getIdentityUniversalAuthClientSecrets(identityId)
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuthClientSecrets(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityGcpAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityGcpAuth, {}, AddIdentityGcpAuthDTO>({
|
||||
return useMutation<IdentityGcpAuth, object, AddIdentityGcpAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
type,
|
||||
@@ -261,16 +279,18 @@ export const useAddIdentityGcpAuth = () => {
|
||||
return identityGcpAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityGcpAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityGcpAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityGcpAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityGcpAuth, {}, UpdateIdentityGcpAuthDTO>({
|
||||
return useMutation<IdentityGcpAuth, object, UpdateIdentityGcpAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
type,
|
||||
@@ -301,16 +321,18 @@ export const useUpdateIdentityGcpAuth = () => {
|
||||
return identityGcpAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityGcpAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityGcpAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityGcpAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityGcpAuth, {}, DeleteIdentityGcpAuthDTO>({
|
||||
return useMutation<IdentityGcpAuth, object, DeleteIdentityGcpAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityGcpAuth }
|
||||
@@ -318,16 +340,18 @@ export const useDeleteIdentityGcpAuth = () => {
|
||||
return identityGcpAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityGcpAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityGcpAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityAwsAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAwsAuth, {}, AddIdentityAwsAuthDTO>({
|
||||
return useMutation<IdentityAwsAuth, object, AddIdentityAwsAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
stsEndpoint,
|
||||
@@ -356,16 +380,18 @@ export const useAddIdentityAwsAuth = () => {
|
||||
return identityAwsAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityAwsAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAwsAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityAwsAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAwsAuth, {}, UpdateIdentityAwsAuthDTO>({
|
||||
return useMutation<IdentityAwsAuth, object, UpdateIdentityAwsAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
stsEndpoint,
|
||||
@@ -394,16 +420,18 @@ export const useUpdateIdentityAwsAuth = () => {
|
||||
return identityAwsAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityAwsAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAwsAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityAwsAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAwsAuth, {}, DeleteIdentityAwsAuthDTO>({
|
||||
return useMutation<IdentityAwsAuth, object, DeleteIdentityAwsAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityAwsAuth }
|
||||
@@ -411,16 +439,18 @@ export const useDeleteIdentityAwsAuth = () => {
|
||||
return identityAwsAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityAwsAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAwsAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityOidcAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityOidcAuth, {}, UpdateIdentityOidcAuthDTO>({
|
||||
return useMutation<IdentityOidcAuth, object, UpdateIdentityOidcAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
accessTokenTTL,
|
||||
@@ -455,16 +485,18 @@ export const useUpdateIdentityOidcAuth = () => {
|
||||
return identityOidcAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityOidcAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityOidcAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityOidcAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityOidcAuth, {}, AddIdentityOidcAuthDTO>({
|
||||
return useMutation<IdentityOidcAuth, object, AddIdentityOidcAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
oidcDiscoveryUrl,
|
||||
@@ -499,16 +531,18 @@ export const useAddIdentityOidcAuth = () => {
|
||||
return identityOidcAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityOidcAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityOidcAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityOidcAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityTokenAuth, {}, DeleteIdentityOidcAuthDTO>({
|
||||
return useMutation<IdentityTokenAuth, object, DeleteIdentityOidcAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityOidcAuth }
|
||||
@@ -516,15 +550,17 @@ export const useDeleteIdentityOidcAuth = () => {
|
||||
return identityOidcAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityOidcAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityOidcAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
export const useUpdateIdentityJwtAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityJwtAuth, {}, UpdateIdentityJwtAuthDTO>({
|
||||
return useMutation<IdentityJwtAuth, object, UpdateIdentityJwtAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
configurationType,
|
||||
@@ -563,16 +599,18 @@ export const useUpdateIdentityJwtAuth = () => {
|
||||
return identityJwtAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityJwtAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityJwtAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityJwtAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityJwtAuth, {}, AddIdentityJwtAuthDTO>({
|
||||
return useMutation<IdentityJwtAuth, object, AddIdentityJwtAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
configurationType,
|
||||
@@ -611,16 +649,18 @@ export const useAddIdentityJwtAuth = () => {
|
||||
return identityJwtAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityJwtAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityJwtAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityJwtAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityTokenAuth, {}, DeleteIdentityJwtAuthDTO>({
|
||||
return useMutation<IdentityTokenAuth, object, DeleteIdentityJwtAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityJwtAuth }
|
||||
@@ -628,16 +668,18 @@ export const useDeleteIdentityJwtAuth = () => {
|
||||
return identityJwtAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityJwtAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityJwtAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityAzureAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAzureAuth, {}, AddIdentityAzureAuthDTO>({
|
||||
return useMutation<IdentityAzureAuth, object, AddIdentityAzureAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
tenantId,
|
||||
@@ -666,16 +708,20 @@ export const useAddIdentityAzureAuth = () => {
|
||||
return identityAzureAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityKubernetesAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityKubernetesAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityKubernetesAuth, {}, AddIdentityKubernetesAuthDTO>({
|
||||
return useMutation<IdentityKubernetesAuth, object, AddIdentityKubernetesAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
kubernetesHost,
|
||||
@@ -710,16 +756,18 @@ export const useAddIdentityKubernetesAuth = () => {
|
||||
return identityKubernetesAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityAzureAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAzureAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityAzureAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAzureAuth, {}, UpdateIdentityAzureAuthDTO>({
|
||||
return useMutation<IdentityAzureAuth, object, UpdateIdentityAzureAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
tenantId,
|
||||
@@ -748,16 +796,18 @@ export const useUpdateIdentityAzureAuth = () => {
|
||||
return identityAzureAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityAzureAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAzureAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityAzureAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAzureAuth, {}, DeleteIdentityAzureAuthDTO>({
|
||||
return useMutation<IdentityAzureAuth, object, DeleteIdentityAzureAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityAzureAuth }
|
||||
@@ -765,16 +815,18 @@ export const useDeleteIdentityAzureAuth = () => {
|
||||
return identityAzureAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityAzureAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAzureAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityKubernetesAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityKubernetesAuth, {}, UpdateIdentityKubernetesAuthDTO>({
|
||||
return useMutation<IdentityKubernetesAuth, object, UpdateIdentityKubernetesAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
kubernetesHost,
|
||||
@@ -809,16 +861,20 @@ export const useUpdateIdentityKubernetesAuth = () => {
|
||||
return identityKubernetesAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityKubernetesAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityKubernetesAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityTokenAuth, {}, DeleteIdentityKubernetesAuthDTO>({
|
||||
return useMutation<IdentityTokenAuth, object, DeleteIdentityKubernetesAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityKubernetesAuth }
|
||||
@@ -826,16 +882,20 @@ export const useDeleteIdentityKubernetesAuth = () => {
|
||||
return identityKubernetesAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityKubernetesAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddIdentityTokenAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityTokenAuth, {}, AddIdentityTokenAuthDTO>({
|
||||
return useMutation<IdentityTokenAuth, object, AddIdentityTokenAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
accessTokenTTL,
|
||||
@@ -858,16 +918,20 @@ export const useAddIdentityTokenAuth = () => {
|
||||
return identityTokenAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityUniversalAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityTokenAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityTokenAuth, {}, UpdateIdentityTokenAuthDTO>({
|
||||
return useMutation<IdentityTokenAuth, object, UpdateIdentityTokenAuthDTO>({
|
||||
mutationFn: async ({
|
||||
identityId,
|
||||
accessTokenTTL,
|
||||
@@ -890,16 +954,20 @@ export const useUpdateIdentityTokenAuth = () => {
|
||||
return identityTokenAuth;
|
||||
},
|
||||
onSuccess: (_, { identityId, organizationId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityUniversalAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteIdentityTokenAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityTokenAuth, {}, DeleteIdentityTokenAuthDTO>({
|
||||
return useMutation<IdentityTokenAuth, object, DeleteIdentityTokenAuthDTO>({
|
||||
mutationFn: async ({ identityId }) => {
|
||||
const {
|
||||
data: { identityTokenAuth }
|
||||
@@ -907,16 +975,18 @@ export const useDeleteIdentityTokenAuth = () => {
|
||||
return identityTokenAuth;
|
||||
},
|
||||
onSuccess: (_, { organizationId, identityId }) => {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityById(identityId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityTokenAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgIdentityMemberships(organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
|
||||
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityTokenAuth(identityId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateTokenIdentityTokenAuth = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<CreateTokenIdentityTokenAuthRes, {}, CreateTokenIdentityTokenAuthDTO>({
|
||||
return useMutation<CreateTokenIdentityTokenAuthRes, object, CreateTokenIdentityTokenAuthDTO>({
|
||||
mutationFn: async ({ identityId, name }) => {
|
||||
const { data } = await apiRequest.post<CreateTokenIdentityTokenAuthRes>(
|
||||
`/api/v1/auth/token-auth/identities/${identityId}/tokens`,
|
||||
@@ -928,14 +998,16 @@ export const useCreateTokenIdentityTokenAuth = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { identityId }) => {
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityTokensTokenAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityTokensTokenAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateIdentityTokenAuthToken = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<IdentityAccessToken, {}, UpdateTokenIdentityTokenAuthDTO>({
|
||||
return useMutation<IdentityAccessToken, object, UpdateTokenIdentityTokenAuthDTO>({
|
||||
mutationFn: async ({ tokenId, name }) => {
|
||||
const {
|
||||
data: { token }
|
||||
@@ -949,14 +1021,16 @@ export const useUpdateIdentityTokenAuthToken = () => {
|
||||
return token;
|
||||
},
|
||||
onSuccess: (_, { identityId }) => {
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityTokensTokenAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityTokensTokenAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRevokeIdentityTokenAuthToken = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<RevokeTokenRes, {}, RevokeTokenDTO>({
|
||||
return useMutation<RevokeTokenRes, object, RevokeTokenDTO>({
|
||||
mutationFn: async ({ tokenId }) => {
|
||||
const { data } = await apiRequest.post<RevokeTokenRes>(
|
||||
`/api/v1/auth/token-auth/tokens/${tokenId}/revoke`
|
||||
@@ -965,7 +1039,9 @@ export const useRevokeIdentityTokenAuthToken = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { identityId }) => {
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityTokensTokenAuth(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityTokensTokenAuth(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import {
|
||||
ClientSecretData,
|
||||
@@ -69,12 +70,7 @@ export const useGetIdentityProjectMemberships = (identityId: string) => {
|
||||
|
||||
export const useGetIdentityUniversalAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityUniversalAuth,
|
||||
unknown,
|
||||
IdentityUniversalAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityUniversalAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
|
||||
@@ -86,7 +82,7 @@ export const useGetIdentityUniversalAuth = (
|
||||
);
|
||||
return identityUniversalAuth;
|
||||
},
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
staleTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
@@ -110,12 +106,7 @@ export const useGetIdentityUniversalAuthClientSecrets = (identityId: string) =>
|
||||
|
||||
export const useGetIdentityGcpAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityGcpAuth,
|
||||
unknown,
|
||||
IdentityGcpAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityGcpAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityGcpAuth(identityId),
|
||||
@@ -128,7 +119,7 @@ export const useGetIdentityGcpAuth = (
|
||||
return identityGcpAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
@@ -136,12 +127,7 @@ export const useGetIdentityGcpAuth = (
|
||||
|
||||
export const useGetIdentityAwsAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityAwsAuth,
|
||||
unknown,
|
||||
IdentityAwsAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityAwsAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityAwsAuth(identityId),
|
||||
@@ -154,7 +140,7 @@ export const useGetIdentityAwsAuth = (
|
||||
return identityAwsAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
@@ -162,12 +148,7 @@ export const useGetIdentityAwsAuth = (
|
||||
|
||||
export const useGetIdentityAzureAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityAzureAuth,
|
||||
unknown,
|
||||
IdentityAzureAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityAzureAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityAzureAuth(identityId),
|
||||
@@ -180,7 +161,7 @@ export const useGetIdentityAzureAuth = (
|
||||
return identityAzureAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
@@ -188,12 +169,7 @@ export const useGetIdentityAzureAuth = (
|
||||
|
||||
export const useGetIdentityKubernetesAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityKubernetesAuth,
|
||||
unknown,
|
||||
IdentityKubernetesAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityKubernetesAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId),
|
||||
@@ -206,7 +182,7 @@ export const useGetIdentityKubernetesAuth = (
|
||||
return identityKubernetesAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
@@ -214,12 +190,7 @@ export const useGetIdentityKubernetesAuth = (
|
||||
|
||||
export const useGetIdentityTokenAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityTokenAuth,
|
||||
unknown,
|
||||
IdentityTokenAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityTokenAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityTokenAuth(identityId),
|
||||
@@ -232,7 +203,7 @@ export const useGetIdentityTokenAuth = (
|
||||
return identityTokenAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
@@ -255,12 +226,7 @@ export const useGetIdentityTokensTokenAuth = (identityId: string) => {
|
||||
|
||||
export const useGetIdentityOidcAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityOidcAuth,
|
||||
unknown,
|
||||
IdentityOidcAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityOidcAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityOidcAuth(identityId),
|
||||
@@ -273,7 +239,7 @@ export const useGetIdentityOidcAuth = (
|
||||
return identityOidcAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
@@ -281,12 +247,7 @@ export const useGetIdentityOidcAuth = (
|
||||
|
||||
export const useGetIdentityJwtAuth = (
|
||||
identityId: string,
|
||||
options?: UseQueryOptions<
|
||||
IdentityJwtAuth,
|
||||
unknown,
|
||||
IdentityJwtAuth,
|
||||
ReturnType<typeof identitiesKeys.getIdentityJwtAuth>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: identitiesKeys.getIdentityJwtAuth(identityId),
|
||||
@@ -300,7 +261,7 @@ export const useGetIdentityJwtAuth = (
|
||||
return identityJwtAuth;
|
||||
},
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
gcTime: 0,
|
||||
...options,
|
||||
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||
});
|
||||
|
||||
@@ -13,13 +13,15 @@ import {
|
||||
export const useCreateIdentityProjectAdditionalPrivilege = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TIdentityProjectPrivilege, {}, TCreateIdentityProjectPrivilegeDTO>({
|
||||
return useMutation<TIdentityProjectPrivilege, object, TCreateIdentityProjectPrivilegeDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v2/identity-project-additional-privilege", dto);
|
||||
return data.privilege;
|
||||
},
|
||||
onSuccess: (_, { projectId, identityId }) => {
|
||||
queryClient.invalidateQueries(identitiyProjectPrivilegeKeys.list({ projectId, identityId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiyProjectPrivilegeKeys.list({ projectId, identityId })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -27,7 +29,7 @@ export const useCreateIdentityProjectAdditionalPrivilege = () => {
|
||||
export const useUpdateIdentityProjectAdditionalPrivilege = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TIdentityProjectPrivilege, {}, TUpdateIdentityProjectPrivlegeDTO>({
|
||||
return useMutation<TIdentityProjectPrivilege, object, TUpdateIdentityProjectPrivlegeDTO>({
|
||||
mutationFn: async ({ projectId, privilegeId, identityId, permissions, slug, type }) => {
|
||||
const { data: res } = await apiRequest.patch(
|
||||
`/api/v2/identity-project-additional-privilege/${privilegeId}`,
|
||||
@@ -43,7 +45,9 @@ export const useUpdateIdentityProjectAdditionalPrivilege = () => {
|
||||
return res.privilege;
|
||||
},
|
||||
onSuccess: (_, { projectId, identityId }) => {
|
||||
queryClient.invalidateQueries(identitiyProjectPrivilegeKeys.list({ projectId, identityId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiyProjectPrivilegeKeys.list({ projectId, identityId })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -51,7 +55,7 @@ export const useUpdateIdentityProjectAdditionalPrivilege = () => {
|
||||
export const useDeleteIdentityProjectAdditionalPrivilege = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TIdentityProjectPrivilege, {}, TDeleteIdentityProjectPrivilegeDTO>({
|
||||
return useMutation<TIdentityProjectPrivilege, object, TDeleteIdentityProjectPrivilegeDTO>({
|
||||
mutationFn: async ({ identityId, projectId, privilegeId }) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v2/identity-project-additional-privilege/${privilegeId}`,
|
||||
@@ -66,7 +70,9 @@ export const useDeleteIdentityProjectAdditionalPrivilege = () => {
|
||||
return data.privilege;
|
||||
},
|
||||
onSuccess: (_, { projectId, identityId }) => {
|
||||
queryClient.invalidateQueries(identitiyProjectPrivilegeKeys.list({ projectId, identityId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiyProjectPrivilegeKeys.list({ projectId, identityId })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ export const useGetOrgIncidentContact = (orgId: string) =>
|
||||
export const useAddIncidentContact = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, AddIncidentContactDTO>({
|
||||
return useMutation<object, object, AddIncidentContactDTO>({
|
||||
mutationFn: async ({ orgId, email }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/organization/${orgId}/incidentContactOrg`, {
|
||||
email
|
||||
@@ -33,7 +33,7 @@ export const useAddIncidentContact = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(incidentContactKeys.getAllContact(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: incidentContactKeys.getAllContact(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -41,7 +41,7 @@ export const useAddIncidentContact = () => {
|
||||
export const useDeleteIncidentContact = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, DeleteIncidentContactDTO>({
|
||||
return useMutation<object, object, DeleteIncidentContactDTO>({
|
||||
mutationFn: async ({ orgId, incidentContactId }) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v1/organization/${orgId}/incidentContactOrg/${incidentContactId}`
|
||||
@@ -49,7 +49,7 @@ export const useDeleteIncidentContact = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(incidentContactKeys.getAllContact(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: incidentContactKeys.getAllContact(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ export * from "./secretSharing";
|
||||
export * from "./secretSnapshots";
|
||||
export * from "./serverDetails";
|
||||
export * from "./serviceTokens";
|
||||
export * from "./ssh-ca";
|
||||
export * from "./sshCa";
|
||||
export * from "./sshCertificateTemplates";
|
||||
export * from "./ssoConfig";
|
||||
export * from "./subscriptions";
|
||||
|
||||
@@ -6,7 +6,7 @@ import { IntegrationAuth, TDuplicateIntegrationAuthDTO } from "./types";
|
||||
|
||||
// For now, this should only be used in the Github app integration flow.
|
||||
export const useDuplicateIntegrationAuth = () => {
|
||||
return useMutation<IntegrationAuth, {}, TDuplicateIntegrationAuthDTO>({
|
||||
return useMutation<IntegrationAuth, object, TDuplicateIntegrationAuthDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<{ integrationAuth: IntegrationAuth }>(
|
||||
`/api/v1/integration-auth/${body.integrationAuthId}/duplicate`,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMutation, useQuery, useQueryClient, UseQueryOptions } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import { workspaceKeys } from "../workspace";
|
||||
import {
|
||||
@@ -513,15 +514,6 @@ const fetchIntegrationAuthOctopusDeployScopeValues = async ({
|
||||
return data;
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthCircleCIOrganizations = async (integrationAuthId: string) => {
|
||||
const {
|
||||
data: { organizations }
|
||||
} = await apiRequest.get<{
|
||||
organizations: CircleCIOrganization[];
|
||||
}>(`/api/v1/integration-auth/${integrationAuthId}/circleci/organizations`);
|
||||
return organizations;
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthById = (integrationAuthId: string) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthById(integrationAuthId),
|
||||
@@ -542,11 +534,7 @@ export const useGetIntegrationAuthApps = (
|
||||
azureDevOpsOrgName?: string;
|
||||
workspaceSlug?: string;
|
||||
},
|
||||
options?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof fetchIntegrationAuthApps>>,
|
||||
unknown,
|
||||
Awaited<ReturnType<typeof fetchIntegrationAuthApps>>
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthApps(integrationAuthId, teamId, workspaceSlug),
|
||||
@@ -818,11 +806,7 @@ export const useGetIntegrationAuthOctopusDeploySpaces = (integrationAuthId: stri
|
||||
|
||||
export const useGetIntegrationAuthOctopusDeployScopeValues = (
|
||||
params: TGetIntegrationAuthOctopusDeployScopeValuesDTO,
|
||||
options?: UseQueryOptions<
|
||||
TOctopusDeployVariableSetScopeValues,
|
||||
unknown,
|
||||
TOctopusDeployVariableSetScopeValues
|
||||
>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) =>
|
||||
useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthOctopusDeployScopeValues(params),
|
||||
@@ -840,7 +824,7 @@ export const useGetIntegrationAuthBitBucketEnvironments = (
|
||||
workspaceSlug: string;
|
||||
repoSlug: string;
|
||||
},
|
||||
options?: UseQueryOptions<BitBucketEnvironment[]>
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthBitBucketEnvironments(
|
||||
@@ -854,6 +838,21 @@ export const useGetIntegrationAuthBitBucketEnvironments = (
|
||||
});
|
||||
};
|
||||
|
||||
const fetchIntegrationAuthCircleCIOrganizations = async (integrationAuthId: string) => {
|
||||
const {
|
||||
data: { organizations }
|
||||
} = await apiRequest.get<{
|
||||
organizations: CircleCIOrganization[];
|
||||
}>(`/api/v1/integration-auth/${integrationAuthId}/circleci/organizations`);
|
||||
return organizations;
|
||||
};
|
||||
export const useGetIntegrationAuthCircleCIOrganizations = (integrationAuthId: string) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthCircleCIOrganizations(integrationAuthId),
|
||||
queryFn: () => fetchIntegrationAuthCircleCIOrganizations(integrationAuthId)
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthNorthflankSecretGroups = ({
|
||||
integrationAuthId,
|
||||
appId
|
||||
@@ -896,13 +895,6 @@ export const useGetIntegrationAuthTeamCityBuildConfigs = ({
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetIntegrationAuthCircleCIOrganizations = (integrationAuthId: string) => {
|
||||
return useQuery({
|
||||
queryKey: integrationAuthKeys.getIntegrationAuthCircleCIOrganizations(integrationAuthId),
|
||||
queryFn: () => fetchIntegrationAuthCircleCIOrganizations(integrationAuthId)
|
||||
});
|
||||
};
|
||||
|
||||
export const useAuthorizeIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -933,7 +925,9 @@ export const useAuthorizeIntegration = () => {
|
||||
return integrationAuth;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceAuthorization(res.workspace));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: { queryKey: workspaceKeys.getWorkspaceAuthorization(res.workspace) }
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -977,7 +971,9 @@ export const useSaveIntegrationAccessToken = () => {
|
||||
return integrationAuth;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceAuthorization(res.workspace));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceAuthorization(res.workspace)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -985,7 +981,7 @@ export const useSaveIntegrationAccessToken = () => {
|
||||
export const useDeleteIntegrationAuths = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, { integration: string; workspaceId: string }>({
|
||||
return useMutation<object, object, { integration: string; workspaceId: string }>({
|
||||
mutationFn: ({ integration, workspaceId }) =>
|
||||
apiRequest.delete(
|
||||
`/api/v1/integration-auth?${new URLSearchParams({
|
||||
@@ -994,8 +990,12 @@ export const useDeleteIntegrationAuths = () => {
|
||||
})}`
|
||||
),
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceAuthorization(workspaceId));
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIntegrations(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1004,11 +1004,15 @@ export const useDeleteIntegrationAuth = () => {
|
||||
// not used
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, { id: string; workspaceId: string }>({
|
||||
return useMutation<object, object, { id: string; workspaceId: string }>({
|
||||
mutationFn: ({ id }) => apiRequest.delete(`/api/v1/integration-auth/${id}`),
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceAuthorization(workspaceId));
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIntegrations(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -85,7 +85,6 @@ export const useCreateIntegration = () => {
|
||||
key: string;
|
||||
value: string;
|
||||
}[];
|
||||
azureLabel?: string;
|
||||
githubVisibility?: string;
|
||||
githubVisibilityRepoIds?: string[];
|
||||
kmsKeyId?: string;
|
||||
@@ -121,7 +120,9 @@ export const useCreateIntegration = () => {
|
||||
return integration;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIntegrations(res.workspace));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIntegrations(res.workspace)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -130,8 +131,8 @@ export const useDeleteIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<
|
||||
{},
|
||||
{},
|
||||
object,
|
||||
object,
|
||||
{ id: string; workspaceId: string; shouldDeleteIntegrationSecrets: boolean }
|
||||
>({
|
||||
mutationFn: ({ id, shouldDeleteIntegrationSecrets }) =>
|
||||
@@ -139,8 +140,12 @@ export const useDeleteIntegration = () => {
|
||||
`/api/v1/integration/${id}?shouldDeleteIntegrationSecrets=${shouldDeleteIntegrationSecrets}`
|
||||
),
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIntegrations(workspaceId));
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceAuthorization(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -166,7 +171,7 @@ export const useGetIntegration = (
|
||||
};
|
||||
|
||||
export const useSyncIntegration = () => {
|
||||
return useMutation<{}, {}, { id: string; workspaceId: string; lastUsed: string }>({
|
||||
return useMutation<object, object, { id: string; workspaceId: string; lastUsed: string }>({
|
||||
mutationFn: ({ id }) => apiRequest.post(`/api/v1/integration/${id}/sync`),
|
||||
onSuccess: () => {
|
||||
createNotification({
|
||||
|
||||
@@ -31,7 +31,7 @@ export const uploadWsKey = async ({ workspaceId, userId, encryptedKey, nonce }:
|
||||
};
|
||||
|
||||
export const useUploadWsKey = () =>
|
||||
useMutation<{}, {}, UploadWsKeyDTO>({
|
||||
useMutation<object, object, UploadWsKeyDTO>({
|
||||
mutationFn: async ({ encryptedKey, nonce, userId, workspaceId }) => {
|
||||
return uploadWsKey({
|
||||
workspaceId,
|
||||
|
||||
@@ -24,7 +24,7 @@ export const useAddExternalKms = (orgId: string) => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(kmsKeys.getExternalKmsList(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getExternalKmsList(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -49,8 +49,8 @@ export const useUpdateExternalKms = (orgId: string) => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { kmsId }) => {
|
||||
queryClient.invalidateQueries(kmsKeys.getExternalKmsList(orgId));
|
||||
queryClient.invalidateQueries(kmsKeys.getExternalKmsById(kmsId));
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getExternalKmsList(orgId) });
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getExternalKmsById(kmsId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -64,7 +64,7 @@ export const useRemoveExternalKms = (orgId: string) => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(kmsKeys.getExternalKmsList(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getExternalKmsList(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -82,7 +82,7 @@ export const useUpdateProjectKms = (projectId: string) => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(kmsKeys.getActiveProjectKms(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getActiveProjectKms(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -98,7 +98,7 @@ export const useLoadProjectKmsBackup = (projectId: string) => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(kmsKeys.getActiveProjectKms(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getActiveProjectKms(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -139,7 +139,7 @@ export const useExternalKmsFetchGcpKeys = (orgId: string) => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(kmsKeys.getExternalKmsList(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: kmsKeys.getExternalKmsList(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,5 +3,6 @@ export {
|
||||
useCreateLDAPGroupMapping,
|
||||
useDeleteLDAPGroupMapping,
|
||||
useTestLDAPConnection,
|
||||
useUpdateLDAPConfig} from "./mutations";
|
||||
useUpdateLDAPConfig
|
||||
} from "./mutations";
|
||||
export { useGetLDAPConfig, useGetLDAPGroupMaps } from "./queries";
|
||||
|
||||
@@ -49,7 +49,7 @@ export const useCreateLDAPConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(ldapConfigKeys.getLDAPConfig(dto.organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: ldapConfigKeys.getLDAPConfig(dto.organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -99,7 +99,7 @@ export const useUpdateLDAPConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(ldapConfigKeys.getLDAPConfig(dto.organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: ldapConfigKeys.getLDAPConfig(dto.organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -123,7 +123,7 @@ export const useCreateLDAPGroupMapping = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, { ldapConfigId }) {
|
||||
queryClient.invalidateQueries(ldapConfigKeys.getLDAPGroupMaps(ldapConfigId));
|
||||
queryClient.invalidateQueries({ queryKey: ldapConfigKeys.getLDAPGroupMaps(ldapConfigId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -144,7 +144,7 @@ export const useDeleteLDAPGroupMapping = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, { ldapConfigId }) {
|
||||
queryClient.invalidateQueries(ldapConfigKeys.getLDAPGroupMaps(ldapConfigId));
|
||||
queryClient.invalidateQueries({ queryKey: ldapConfigKeys.getLDAPGroupMaps(ldapConfigId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ export const useGetLDAPConfig = (organizationId: string) => {
|
||||
);
|
||||
|
||||
return data;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { workspaceKeys } from "../workspace";
|
||||
import { ProjectType } from "../workspace/types";
|
||||
|
||||
export const useImportEnvKey = () => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -21,7 +20,9 @@ export const useImportEnvKey = () => {
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
onUploadProgress: (progressEvent) => {
|
||||
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
||||
const percentCompleted = Math.round(
|
||||
(progressEvent.loaded * 100) / (progressEvent?.total || 1)
|
||||
);
|
||||
console.log(`Upload Progress: ${percentCompleted}%`);
|
||||
}
|
||||
});
|
||||
@@ -32,7 +33,9 @@ export const useImportEnvKey = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(ProjectType.SecretManager));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -53,8 +53,8 @@ export const useUpdateOIDCConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(oidcConfigKeys.getOIDCConfig(dto.orgSlug));
|
||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||
queryClient.invalidateQueries({ queryKey: oidcConfigKeys.getOIDCConfig(dto.orgSlug) });
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -107,7 +107,7 @@ export const useCreateOIDCConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(oidcConfigKeys.getOIDCConfig(dto.orgSlug));
|
||||
queryClient.invalidateQueries({ queryKey: oidcConfigKeys.getOIDCConfig(dto.orgSlug) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ export const useGetOIDCConfig = (orgSlug: string) => {
|
||||
);
|
||||
|
||||
return data;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
||||
|
||||
@@ -42,7 +41,8 @@ export const organizationKeys = {
|
||||
}: TListOrgIdentitiesDTO) =>
|
||||
[...organizationKeys.getOrgIdentityMemberships(orgId), params] as const,
|
||||
getOrgGroups: (orgId: string) => [{ orgId }, "organization-groups"] as const,
|
||||
getOrgIntegrationAuths: (orgId: string) => [{ orgId }, "integration-auths"] as const
|
||||
getOrgIntegrationAuths: (orgId: string) => [{ orgId }, "integration-auths"] as const,
|
||||
getOrgById: (orgId: string) => ["organization", { orgId }]
|
||||
};
|
||||
|
||||
export const fetchOrganizations = async () => {
|
||||
@@ -61,6 +61,22 @@ export const useGetOrganizations = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchOrganizationById = async (id: string) => {
|
||||
const {
|
||||
data: { organization }
|
||||
} = await apiRequest.get<{ organization: Organization }>(`/api/v1/organization/${id}`);
|
||||
return organization;
|
||||
};
|
||||
|
||||
export const useGetOrganizationById = (id: string) => {
|
||||
return useQuery({
|
||||
queryKey: organizationKeys.getOrgById(id),
|
||||
queryFn: async () => {
|
||||
return fetchOrganizationById(id);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: true }) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -68,7 +84,7 @@ export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: tr
|
||||
mutationFn: async ({ name }: { name: string }) => {
|
||||
const {
|
||||
data: { organization }
|
||||
} = await apiRequest.post<{ organization: { id: string } }>("/api/v2/organizations", {
|
||||
} = await apiRequest.post("/api/v2/organizations", {
|
||||
name
|
||||
});
|
||||
|
||||
@@ -76,7 +92,7 @@ export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: tr
|
||||
},
|
||||
onSuccess: () => {
|
||||
if (options?.invalidate) {
|
||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -84,7 +100,7 @@ export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: tr
|
||||
|
||||
export const useUpdateOrg = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, UpdateOrgDTO>({
|
||||
return useMutation<object, object, UpdateOrgDTO>({
|
||||
mutationFn: ({
|
||||
name,
|
||||
authEnforced,
|
||||
@@ -106,7 +122,7 @@ export const useUpdateOrg = () => {
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -210,7 +226,9 @@ export const useUpdateOrgBillingDetails = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgBillingDetails(dto.organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgBillingDetails(dto.organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -255,7 +273,9 @@ export const useAddOrgPmtMethod = () => {
|
||||
return url;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgPmtMethods(dto.organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPmtMethods(dto.organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -278,7 +298,9 @@ export const useDeleteOrgPmtMethod = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgPmtMethods(dto.organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPmtMethods(dto.organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -321,7 +343,9 @@ export const useAddOrgTaxId = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgTaxIds(dto.organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgTaxIds(dto.organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -338,7 +362,9 @@ export const useDeleteOrgTaxId = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgTaxIds(dto.organizationId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgTaxIds(dto.organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -438,30 +464,41 @@ export const useDeleteOrgById = () => {
|
||||
return useMutation({
|
||||
mutationFn: async ({ organizationId }: { organizationId: string }) => {
|
||||
const {
|
||||
data: { organization, accessToken }
|
||||
} = await apiRequest.delete<{ organization: Organization; accessToken: string }>(
|
||||
data: { organization }
|
||||
} = await apiRequest.delete<{ organization: Organization }>(
|
||||
`/api/v2/organizations/${organizationId}`
|
||||
);
|
||||
SecurityClient.setToken(accessToken);
|
||||
localStorage.removeItem("orgData.id");
|
||||
|
||||
return organization;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgPlanBillingInfo(dto.organizationId));
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgPlanTable(dto.organizationId));
|
||||
queryClient.invalidateQueries(
|
||||
organizationKeys.getOrgPlansTable(dto.organizationId, "monthly")
|
||||
); // You might need to invalidate for 'yearly' as well.
|
||||
queryClient.invalidateQueries(
|
||||
organizationKeys.getOrgPlansTable(dto.organizationId, "yearly")
|
||||
);
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgBillingDetails(dto.organizationId));
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgPmtMethods(dto.organizationId));
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgTaxIds(dto.organizationId));
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgInvoices(dto.organizationId));
|
||||
queryClient.invalidateQueries(organizationKeys.getOrgLicenses(dto.organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPlanBillingInfo(dto.organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPlanTable(dto.organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPlansTable(dto.organizationId, "monthly")
|
||||
}); // You might need to invalidate for 'yearly' as well.
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPlansTable(dto.organizationId, "yearly")
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgBillingDetails(dto.organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgPmtMethods(dto.organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgTaxIds(dto.organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgInvoices(dto.organizationId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: organizationKeys.getOrgLicenses(dto.organizationId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,20 +8,20 @@ import { TCreatePkiAlertDTO, TDeletePkiAlertDTO, TPkiAlert, TUpdatePkiAlertDTO }
|
||||
|
||||
export const useCreatePkiAlert = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiAlert, {}, TCreatePkiAlertDTO>({
|
||||
return useMutation<TPkiAlert, object, TCreatePkiAlertDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data: alert } = await apiRequest.post<TPkiAlert>("/api/v1/pki/alerts", body);
|
||||
return alert;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiAlerts(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdatePkiAlert = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiAlert, {}, TUpdatePkiAlertDTO>({
|
||||
return useMutation<TPkiAlert, object, TUpdatePkiAlertDTO>({
|
||||
mutationFn: async ({ alertId, ...body }) => {
|
||||
const { data: alert } = await apiRequest.patch<TPkiAlert>(
|
||||
`/api/v1/pki/alerts/${alertId}`,
|
||||
@@ -30,22 +30,22 @@ export const useUpdatePkiAlert = () => {
|
||||
return alert;
|
||||
},
|
||||
onSuccess: (_, { projectId, alertId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiAlerts(projectId));
|
||||
queryClient.invalidateQueries(pkiAlertKeys.getPkiAlertById(alertId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: pkiAlertKeys.getPkiAlertById(alertId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeletePkiAlert = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiAlert, {}, TDeletePkiAlertDTO>({
|
||||
return useMutation<TPkiAlert, object, TDeletePkiAlertDTO>({
|
||||
mutationFn: async ({ alertId }) => {
|
||||
const { data: alert } = await apiRequest.delete<TPkiAlert>(`/api/v1/pki/alerts/${alertId}`);
|
||||
return alert;
|
||||
},
|
||||
onSuccess: (_, { projectId, alertId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiAlerts(projectId));
|
||||
queryClient.invalidateQueries(pkiAlertKeys.getPkiAlertById(alertId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: pkiAlertKeys.getPkiAlertById(alertId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,5 +3,6 @@ export {
|
||||
useCreatePkiCollection,
|
||||
useDeletePkiCollection,
|
||||
useRemoveItemFromPkiCollection,
|
||||
useUpdatePkiCollection} from "./mutations";
|
||||
useUpdatePkiCollection
|
||||
} from "./mutations";
|
||||
export { useGetPkiCollectionById, useListPkiCollectionItems } from "./queries";
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
|
||||
export const useCreatePkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollection, {}, TCreatePkiCollectionDTO>({
|
||||
return useMutation<TPkiCollection, object, TCreatePkiCollectionDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data: pkiCollection } = await apiRequest.post<TPkiCollection>(
|
||||
"/api/v1/pki/collections",
|
||||
@@ -25,14 +25,16 @@ export const useCreatePkiCollection = () => {
|
||||
return pkiCollection;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiCollections(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdatePkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollection, {}, TUpdatePkiCollectionTO>({
|
||||
return useMutation<TPkiCollection, object, TUpdatePkiCollectionTO>({
|
||||
mutationFn: async ({ collectionId, ...body }) => {
|
||||
const { data: pkiCollection } = await apiRequest.patch<TPkiCollection>(
|
||||
`/api/v1/pki/collections/${collectionId}`,
|
||||
@@ -41,15 +43,19 @@ export const useUpdatePkiCollection = () => {
|
||||
return pkiCollection;
|
||||
},
|
||||
onSuccess: (_, { projectId, collectionId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiCollections(projectId));
|
||||
queryClient.invalidateQueries(pkiCollectionKeys.getPkiCollectionById(collectionId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeletePkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollection, {}, TDeletePkiCollectionDTO>({
|
||||
return useMutation<TPkiCollection, object, TDeletePkiCollectionDTO>({
|
||||
mutationFn: async ({ collectionId }) => {
|
||||
const { data: pkiCollection } = await apiRequest.delete<TPkiCollection>(
|
||||
`/api/v1/pki/collections/${collectionId}`
|
||||
@@ -57,15 +63,19 @@ export const useDeletePkiCollection = () => {
|
||||
return pkiCollection;
|
||||
},
|
||||
onSuccess: (_, { projectId, collectionId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiCollections(projectId));
|
||||
queryClient.invalidateQueries(pkiCollectionKeys.getPkiCollectionById(collectionId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddItemToPkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollectionItem, {}, TAddItemToPkiCollectionDTO>({
|
||||
return useMutation<TPkiCollectionItem, object, TAddItemToPkiCollectionDTO>({
|
||||
mutationFn: async ({ collectionId, type, itemId }) => {
|
||||
const { data: pkiCollectionItem } = await apiRequest.post<TPkiCollectionItem>(
|
||||
`/api/v1/pki/collections/${collectionId}/items`,
|
||||
@@ -77,14 +87,16 @@ export const useAddItemToPkiCollection = () => {
|
||||
return pkiCollectionItem;
|
||||
},
|
||||
onSuccess: (_, { collectionId }) => {
|
||||
queryClient.invalidateQueries(pkiCollectionKeys.getPkiCollectionItems(collectionId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: pkiCollectionKeys.getPkiCollectionItems(collectionId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRemoveItemFromPkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollectionItem, {}, TRemoveItemFromPkiCollectionDTO>({
|
||||
return useMutation<TPkiCollectionItem, object, TRemoveItemFromPkiCollectionDTO>({
|
||||
mutationFn: async ({ collectionId, itemId }) => {
|
||||
const { data: pkiCollectionItem } = await apiRequest.delete<TPkiCollectionItem>(
|
||||
`/api/v1/pki/collections/${collectionId}/items/${itemId}`
|
||||
@@ -92,7 +104,9 @@ export const useRemoveItemFromPkiCollection = () => {
|
||||
return pkiCollectionItem;
|
||||
},
|
||||
onSuccess: (_, { collectionId }) => {
|
||||
queryClient.invalidateQueries(pkiCollectionKeys.getPkiCollectionItems(collectionId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: pkiCollectionKeys.getPkiCollectionItems(collectionId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export enum EnforcementLevel {
|
||||
Hard = "hard",
|
||||
Soft = "soft"
|
||||
Hard = "hard",
|
||||
Soft = "soft"
|
||||
}
|
||||
|
||||
export enum PolicyType {
|
||||
ChangePolicy = "change",
|
||||
AccessPolicy = "access"
|
||||
ChangePolicy = "change",
|
||||
AccessPolicy = "access"
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export const useCreateProjectTemplate = () => {
|
||||
|
||||
return data.projectTemplate;
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries(projectTemplateKeys.list())
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: projectTemplateKeys.list() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -36,8 +36,8 @@ export const useUpdateProjectTemplate = () => {
|
||||
return data.projectTemplate;
|
||||
},
|
||||
onSuccess: (_, { templateId }) => {
|
||||
queryClient.invalidateQueries(projectTemplateKeys.list());
|
||||
queryClient.invalidateQueries(projectTemplateKeys.byId(templateId));
|
||||
queryClient.invalidateQueries({ queryKey: projectTemplateKeys.list() });
|
||||
queryClient.invalidateQueries({ queryKey: projectTemplateKeys.byId(templateId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -51,8 +51,8 @@ export const useDeleteProjectTemplate = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { templateId }) => {
|
||||
queryClient.invalidateQueries(projectTemplateKeys.list());
|
||||
queryClient.invalidateQueries(projectTemplateKeys.byId(templateId));
|
||||
queryClient.invalidateQueries({ queryKey: projectTemplateKeys.list() });
|
||||
queryClient.invalidateQueries({ queryKey: projectTemplateKeys.byId(templateId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -13,13 +13,15 @@ import {
|
||||
export const useCreateProjectUserAdditionalPrivilege = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ privilege: TProjectUserPrivilege }, {}, TCreateProjectUserPrivilegeDTO>({
|
||||
return useMutation<{ privilege: TProjectUserPrivilege }, object, TCreateProjectUserPrivilegeDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/user-project-additional-privilege", dto);
|
||||
return data.privilege;
|
||||
},
|
||||
onSuccess: (_, { projectMembershipId }) => {
|
||||
queryClient.invalidateQueries(projectUserPrivilegeKeys.list(projectMembershipId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: projectUserPrivilegeKeys.list(projectMembershipId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -27,7 +29,7 @@ export const useCreateProjectUserAdditionalPrivilege = () => {
|
||||
export const useUpdateProjectUserAdditionalPrivilege = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ privilege: TProjectUserPrivilege }, {}, TUpdateProjectUserPrivlegeDTO>({
|
||||
return useMutation<{ privilege: TProjectUserPrivilege }, object, TUpdateProjectUserPrivlegeDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch(
|
||||
`/api/v1/user-project-additional-privilege/${dto.privilegeId}`,
|
||||
@@ -36,7 +38,9 @@ export const useUpdateProjectUserAdditionalPrivilege = () => {
|
||||
return data.privilege;
|
||||
},
|
||||
onSuccess: (_, { projectMembershipId }) => {
|
||||
queryClient.invalidateQueries(projectUserPrivilegeKeys.list(projectMembershipId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: projectUserPrivilegeKeys.list(projectMembershipId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -44,7 +48,7 @@ export const useUpdateProjectUserAdditionalPrivilege = () => {
|
||||
export const useDeleteProjectUserAdditionalPrivilege = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ privilege: TProjectUserPrivilege }, {}, TDeleteProjectUserPrivilegeDTO>({
|
||||
return useMutation<{ privilege: TProjectUserPrivilege }, object, TDeleteProjectUserPrivilegeDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v1/user-project-additional-privilege/${dto.privilegeId}`
|
||||
@@ -52,7 +56,9 @@ export const useDeleteProjectUserAdditionalPrivilege = () => {
|
||||
return data.privilege;
|
||||
},
|
||||
onSuccess: (_, { projectMembershipId }) => {
|
||||
queryClient.invalidateQueries(projectUserPrivilegeKeys.list(projectMembershipId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: projectUserPrivilegeKeys.list(projectMembershipId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,14 +8,14 @@ import { TRateLimit } from "./types";
|
||||
export const useUpdateRateLimit = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TRateLimit, {}, TRateLimit>({
|
||||
return useMutation<TRateLimit, object, TRateLimit>({
|
||||
mutationFn: async (opt) => {
|
||||
const { data } = await apiRequest.put<{ rateLimit: TRateLimit }>("/api/v1/rate-limit", opt);
|
||||
return data.rateLimit;
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(rateLimitQueryKeys.rateLimit(), data);
|
||||
queryClient.invalidateQueries(rateLimitQueryKeys.rateLimit());
|
||||
queryClient.invalidateQueries({ queryKey: rateLimitQueryKeys.rateLimit() });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
import { MutationCache, QueryClient } from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
// akhilmhdh: doing individual imports to avoid cyclic import error
|
||||
import { Button } from "@app/components/v2/Button";
|
||||
import { Modal, ModalContent, ModalTrigger } from "@app/components/v2/Modal";
|
||||
import { Table, TableContainer, TBody, Td, Th, THead, Tr } from "@app/components/v2/Table";
|
||||
import {
|
||||
formatedConditionsOperatorNames,
|
||||
PermissionConditionOperators
|
||||
} from "@app/context/ProjectPermissionContext/types";
|
||||
|
||||
import { ApiErrorTypes, TApiErrors } from "./types";
|
||||
|
||||
// this is saved in react-query cache
|
||||
export const SIGNUP_TEMP_TOKEN_CACHE_KEY = ["infisical__signup-temp-token"];
|
||||
export const MFA_TEMP_TOKEN_CACHE_KEY = ["infisical__mfa-temp-token"];
|
||||
export const AUTH_TOKEN_CACHE_KEY = ["infisical__auth-token"];
|
||||
|
||||
const camelCaseToSpaces = (input: string) => {
|
||||
return input.replace(/([a-z])([A-Z])/g, "$1 $2");
|
||||
};
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
mutationCache: new MutationCache({
|
||||
onError: (error) => {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const serverResponse = error.response?.data as TApiErrors;
|
||||
if (serverResponse?.error === ApiErrorTypes.ValidationError) {
|
||||
createNotification(
|
||||
{
|
||||
title: "Validation Error",
|
||||
type: "error",
|
||||
text: "Please check the input and try again.",
|
||||
callToAction: (
|
||||
<Modal>
|
||||
<ModalTrigger asChild>
|
||||
<Button variant="outline_bg" size="xs">
|
||||
Show more
|
||||
</Button>
|
||||
</ModalTrigger>
|
||||
<ModalContent title="Validation Error Details">
|
||||
<TableContainer>
|
||||
<Table>
|
||||
<THead>
|
||||
<Tr>
|
||||
<Th>Field</Th>
|
||||
<Th>Issue</Th>
|
||||
</Tr>
|
||||
</THead>
|
||||
<TBody>
|
||||
{serverResponse.message?.map(({ message, path }) => (
|
||||
<Tr key={path.join(".")}>
|
||||
<Td>{path.join(".")}</Td>
|
||||
<Td>{message.toLowerCase()}</Td>
|
||||
</Tr>
|
||||
))}
|
||||
</TBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
),
|
||||
copyActions: [
|
||||
{
|
||||
value: serverResponse.reqId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${serverResponse.reqId}`
|
||||
}
|
||||
]
|
||||
},
|
||||
{ closeOnClick: false }
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (serverResponse?.error === ApiErrorTypes.ForbiddenError) {
|
||||
createNotification(
|
||||
{
|
||||
title: "Forbidden Access",
|
||||
type: "error",
|
||||
text: `${serverResponse.message}.`,
|
||||
callToAction: serverResponse?.details?.length ? (
|
||||
<Modal>
|
||||
<ModalTrigger asChild>
|
||||
<Button variant="outline_bg" size="xs">
|
||||
Show more
|
||||
</Button>
|
||||
</ModalTrigger>
|
||||
<ModalContent
|
||||
title="Validation Rules"
|
||||
subTitle="Please review the allowed rules below."
|
||||
>
|
||||
<div className="flex flex-col gap-2">
|
||||
{serverResponse.details?.map((el, index) => {
|
||||
const hasConditions = Boolean(Object.keys(el.conditions || {}).length);
|
||||
return (
|
||||
<div
|
||||
key={`Forbidden-error-details-${index + 1}`}
|
||||
className="rounded-md border border-gray-600 p-4"
|
||||
>
|
||||
<div>
|
||||
{el.inverted ? "Cannot" : "Can"}{" "}
|
||||
<span className="text-yellow-600">
|
||||
{el.action.toString().replaceAll(",", ", ")}
|
||||
</span>{" "}
|
||||
{el.subject.toString()} {hasConditions && "with conditions:"}
|
||||
</div>
|
||||
{hasConditions && (
|
||||
<ul className="flex list-disc flex-col gap-1 pl-5 pt-2 text-sm">
|
||||
{Object.keys(el.conditions || {}).flatMap((field, fieldIndex) => {
|
||||
const operators = (
|
||||
el.conditions as Record<
|
||||
string,
|
||||
| string
|
||||
| { [K in PermissionConditionOperators]: string | string[] }
|
||||
>
|
||||
)[field];
|
||||
|
||||
const formattedFieldName = camelCaseToSpaces(field).toLowerCase();
|
||||
if (typeof operators === "string") {
|
||||
return (
|
||||
<li
|
||||
key={`Forbidden-error-details-${index + 1}-${
|
||||
fieldIndex + 1
|
||||
}`}
|
||||
>
|
||||
<span className="font-bold capitalize">
|
||||
{formattedFieldName}
|
||||
</span>{" "}
|
||||
<span className="text-mineshaft-200">equal to</span>{" "}
|
||||
<span className="text-yellow-600">{operators}</span>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
return Object.keys(operators).map((operator, operatorIndex) => (
|
||||
<li
|
||||
key={`Forbidden-error-details-${index + 1}-${
|
||||
fieldIndex + 1
|
||||
}-${operatorIndex + 1}`}
|
||||
>
|
||||
<span className="font-bold capitalize">
|
||||
{formattedFieldName}
|
||||
</span>{" "}
|
||||
<span className="text-mineshaft-200">
|
||||
{
|
||||
formatedConditionsOperatorNames[
|
||||
operator as PermissionConditionOperators
|
||||
]
|
||||
}
|
||||
</span>{" "}
|
||||
<span className="text-yellow-600">
|
||||
{operators[
|
||||
operator as PermissionConditionOperators
|
||||
].toString()}
|
||||
</span>
|
||||
</li>
|
||||
));
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
) : undefined,
|
||||
copyActions: [
|
||||
{
|
||||
value: serverResponse.reqId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${serverResponse.reqId}`
|
||||
}
|
||||
]
|
||||
},
|
||||
{ closeOnClick: false }
|
||||
);
|
||||
return;
|
||||
}
|
||||
createNotification({
|
||||
title: "Bad Request",
|
||||
type: "error",
|
||||
text: `${serverResponse.message}.`,
|
||||
copyActions: [
|
||||
{
|
||||
value: serverResponse.reqId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${serverResponse.reqId}`
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}),
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 1
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// memory token storage will be moved to apiRequest module until securityclient is completely depreciated
|
||||
// then all the getters will be also hidden scoped to apiRequest only
|
||||
const MemoryTokenStorage = () => {
|
||||
let authToken: string;
|
||||
|
||||
return {
|
||||
setToken: (token: string) => {
|
||||
authToken = token;
|
||||
},
|
||||
getToken: () => authToken
|
||||
};
|
||||
};
|
||||
|
||||
const signUpTempTokenStorage = MemoryTokenStorage();
|
||||
const mfaAuthTokenStorage = MemoryTokenStorage();
|
||||
const authTokenStorage = MemoryTokenStorage();
|
||||
|
||||
// set token in memory cache
|
||||
export const setSignupTempToken = signUpTempTokenStorage.setToken;
|
||||
|
||||
export const setMfaTempToken = mfaAuthTokenStorage.setToken;
|
||||
|
||||
export const setAuthToken = authTokenStorage.setToken;
|
||||
|
||||
export const getSignupTempToken = signUpTempTokenStorage.getToken;
|
||||
export const getMfaTempToken = mfaAuthTokenStorage.getToken;
|
||||
export const getAuthToken = authTokenStorage.getToken;
|
||||
|
||||
export const isLoggedIn = () => Boolean(getAuthToken());
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
export const useCreateProjectRole = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TProjectRole, {}, TCreateProjectRoleDTO>({
|
||||
return useMutation<TProjectRole, object, TCreateProjectRoleDTO>({
|
||||
mutationFn: async ({ projectId, ...dto }: TCreateProjectRoleDTO) => {
|
||||
const {
|
||||
data: { role }
|
||||
@@ -26,7 +26,7 @@ export const useCreateProjectRole = () => {
|
||||
return role;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getProjectRoles(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getProjectRoles(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -34,7 +34,7 @@ export const useCreateProjectRole = () => {
|
||||
export const useUpdateProjectRole = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TProjectRole, {}, TUpdateProjectRoleDTO>({
|
||||
return useMutation<TProjectRole, object, TUpdateProjectRoleDTO>({
|
||||
mutationFn: async ({ id, projectId, ...dto }: TUpdateProjectRoleDTO) => {
|
||||
const {
|
||||
data: { role }
|
||||
@@ -42,9 +42,11 @@ export const useUpdateProjectRole = () => {
|
||||
return role;
|
||||
},
|
||||
onSuccess: (_, { projectId, slug }) => {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getProjectRoles(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getProjectRoles(projectId) });
|
||||
if (slug) {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getProjectRoleBySlug(projectId, slug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: roleQueryKeys.getProjectRoleBySlug(projectId, slug)
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -52,7 +54,7 @@ export const useUpdateProjectRole = () => {
|
||||
|
||||
export const useDeleteProjectRole = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TProjectRole, {}, TDeleteProjectRoleDTO>({
|
||||
return useMutation<TProjectRole, object, TDeleteProjectRoleDTO>({
|
||||
mutationFn: async ({ projectId, id }: TDeleteProjectRoleDTO) => {
|
||||
const {
|
||||
data: { role }
|
||||
@@ -60,7 +62,7 @@ export const useDeleteProjectRole = () => {
|
||||
return role;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getProjectRoles(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getProjectRoles(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -68,7 +70,7 @@ export const useDeleteProjectRole = () => {
|
||||
export const useCreateOrgRole = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TOrgRole, {}, TCreateOrgRoleDTO>({
|
||||
return useMutation<TOrgRole, object, TCreateOrgRoleDTO>({
|
||||
mutationFn: async ({ orgId, permissions, ...dto }: TCreateOrgRoleDTO) => {
|
||||
const {
|
||||
data: { role }
|
||||
@@ -80,7 +82,7 @@ export const useCreateOrgRole = () => {
|
||||
return role;
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getOrgRoles(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getOrgRoles(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -88,7 +90,7 @@ export const useCreateOrgRole = () => {
|
||||
export const useUpdateOrgRole = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TOrgRole, {}, TUpdateOrgRoleDTO>({
|
||||
return useMutation<TOrgRole, object, TUpdateOrgRoleDTO>({
|
||||
mutationFn: async ({ id, orgId, permissions, ...dto }: TUpdateOrgRoleDTO) => {
|
||||
const {
|
||||
data: { role }
|
||||
@@ -100,8 +102,8 @@ export const useUpdateOrgRole = () => {
|
||||
return role;
|
||||
},
|
||||
onSuccess: (_, { id, orgId }) => {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getOrgRoles(orgId));
|
||||
queryClient.invalidateQueries(roleQueryKeys.getOrgRole(orgId, id));
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getOrgRoles(orgId) });
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getOrgRole(orgId, id) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -109,7 +111,7 @@ export const useUpdateOrgRole = () => {
|
||||
export const useDeleteOrgRole = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<TOrgRole, {}, TDeleteOrgRoleDTO>({
|
||||
return useMutation<TOrgRole, object, TDeleteOrgRoleDTO>({
|
||||
mutationFn: async ({ orgId, id }: TDeleteOrgRoleDTO) => {
|
||||
const {
|
||||
data: { role }
|
||||
@@ -120,8 +122,8 @@ export const useDeleteOrgRole = () => {
|
||||
return role;
|
||||
},
|
||||
onSuccess: (_, { id, orgId }) => {
|
||||
queryClient.invalidateQueries(roleQueryKeys.getOrgRoles(orgId));
|
||||
queryClient.invalidateQueries(roleQueryKeys.getOrgRole(orgId, id));
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getOrgRoles(orgId) });
|
||||
queryClient.invalidateQueries({ queryKey: roleQueryKeys.getOrgRole(orgId, id) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ const glob: JsInterpreter<FieldCondition<string>> = (node, object, context) => {
|
||||
return picomatch.isMatch(secretPath, permissionSecretGlobPath, { strictSlashes: false });
|
||||
};
|
||||
|
||||
const conditionsMatcher = buildMongoQueryMatcher({ $glob }, { glob });
|
||||
export const conditionsMatcher = buildMongoQueryMatcher({ $glob }, { glob });
|
||||
|
||||
export const roleQueryKeys = {
|
||||
getProjectRoles: (projectId: string) => ["roles", { projectId }] as const,
|
||||
@@ -107,7 +107,7 @@ export const useGetOrgRole = (orgId: string, roleId: string) =>
|
||||
enabled: Boolean(orgId && roleId)
|
||||
});
|
||||
|
||||
const getUserOrgPermissions = async ({ orgId }: TGetUserOrgPermissionsDTO) => {
|
||||
export const fetchUserOrgPermissions = async ({ orgId }: TGetUserOrgPermissionsDTO) => {
|
||||
if (orgId === "") return { permissions: [], membership: null };
|
||||
|
||||
const { data } = await apiRequest.get<{
|
||||
@@ -121,7 +121,7 @@ const getUserOrgPermissions = async ({ orgId }: TGetUserOrgPermissionsDTO) => {
|
||||
export const useGetUserOrgPermissions = ({ orgId }: TGetUserOrgPermissionsDTO) =>
|
||||
useQuery({
|
||||
queryKey: roleQueryKeys.getUserOrgPermissions({ orgId }),
|
||||
queryFn: () => getUserOrgPermissions({ orgId }),
|
||||
queryFn: () => fetchUserOrgPermissions({ orgId }),
|
||||
// enabled: Boolean(orgId),
|
||||
select: (data) => {
|
||||
const rule = unpackRules<RawRuleOf<MongoAbility<OrgPermissionSet>>>(data.permissions);
|
||||
@@ -130,7 +130,9 @@ export const useGetUserOrgPermissions = ({ orgId }: TGetUserOrgPermissionsDTO) =
|
||||
}
|
||||
});
|
||||
|
||||
const getUserProjectPermissions = async ({ workspaceId }: TGetUserProjectPermissionDTO) => {
|
||||
export const fetchUserProjectPermissions = async ({
|
||||
workspaceId
|
||||
}: TGetUserProjectPermissionDTO) => {
|
||||
const { data } = await apiRequest.get<{
|
||||
data: {
|
||||
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
|
||||
@@ -144,7 +146,7 @@ const getUserProjectPermissions = async ({ workspaceId }: TGetUserProjectPermiss
|
||||
export const useGetUserProjectPermissions = ({ workspaceId }: TGetUserProjectPermissionDTO) =>
|
||||
useQuery({
|
||||
queryKey: roleQueryKeys.getUserProjectPermissions({ workspaceId }),
|
||||
queryFn: () => getUserProjectPermissions({ workspaceId }),
|
||||
queryFn: () => fetchUserProjectPermissions({ workspaceId }),
|
||||
enabled: Boolean(workspaceId),
|
||||
select: (data) => {
|
||||
const rule = unpackRules<RawRuleOf<MongoAbility<ProjectPermissionSet>>>(data.permissions);
|
||||
|
||||
@@ -56,7 +56,7 @@ export type TGetUserProjectPermissionDTO = {
|
||||
export type TCreateOrgRoleDTO = {
|
||||
orgId: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
description?: string;
|
||||
slug: string;
|
||||
permissions: TPermission[];
|
||||
};
|
||||
@@ -74,7 +74,7 @@ export type TDeleteOrgRoleDTO = {
|
||||
export type TCreateProjectRoleDTO = {
|
||||
projectId: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
description?: string;
|
||||
slug: string;
|
||||
permissions: TProjectPermission[];
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CreateScimTokenDTO, CreateScimTokenRes, DeleteScimTokenDTO } from "./ty
|
||||
|
||||
export const useCreateScimToken = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<CreateScimTokenRes, {}, CreateScimTokenDTO>({
|
||||
return useMutation<CreateScimTokenRes, object, CreateScimTokenDTO>({
|
||||
mutationFn: async ({ organizationId, description, ttlDays }) => {
|
||||
const { data } = await apiRequest.post("/api/v1/scim/scim-tokens", {
|
||||
organizationId,
|
||||
@@ -18,20 +18,20 @@ export const useCreateScimToken = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
queryClient.invalidateQueries(scimKeys.getScimTokens(organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: scimKeys.getScimTokens(organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteScimToken = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<CreateScimTokenRes, {}, DeleteScimTokenDTO>({
|
||||
return useMutation<CreateScimTokenRes, object, DeleteScimTokenDTO>({
|
||||
mutationFn: async ({ scimTokenId }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/scim/scim-tokens/${scimTokenId}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
queryClient.invalidateQueries(scimKeys.getScimTokens(organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: scimKeys.getScimTokens(organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { TCreateSecretPolicyDTO, TDeleteSecretPolicyDTO, TUpdateSecretPolicyDTO
|
||||
export const useCreateSecretApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretPolicyDTO>({
|
||||
return useMutation<object, object, TCreateSecretPolicyDTO>({
|
||||
mutationFn: async ({
|
||||
environment,
|
||||
workspaceId,
|
||||
@@ -30,7 +30,9 @@ export const useCreateSecretApprovalPolicy = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretApprovalKeys.getApprovalPolicies(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -38,7 +40,7 @@ export const useCreateSecretApprovalPolicy = () => {
|
||||
export const useUpdateSecretApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretPolicyDTO>({
|
||||
return useMutation<object, object, TUpdateSecretPolicyDTO>({
|
||||
mutationFn: async ({ id, approvers, approvals, secretPath, name, enforcementLevel }) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/secret-approvals/${id}`, {
|
||||
approvals,
|
||||
@@ -50,7 +52,9 @@ export const useUpdateSecretApprovalPolicy = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretApprovalKeys.getApprovalPolicies(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -58,13 +62,15 @@ export const useUpdateSecretApprovalPolicy = () => {
|
||||
export const useDeleteSecretApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretPolicyDTO>({
|
||||
return useMutation<object, object, TDeleteSecretPolicyDTO>({
|
||||
mutationFn: async ({ id }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/secret-approvals/${id}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretApprovalKeys.getApprovalPolicies(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import {
|
||||
TGetSecretApprovalPoliciesDTO,
|
||||
@@ -28,14 +29,7 @@ const fetchApprovalPolicies = async (workspaceId: string) => {
|
||||
export const useGetSecretApprovalPolicies = ({
|
||||
workspaceId,
|
||||
options = {}
|
||||
}: TGetSecretApprovalPoliciesDTO & {
|
||||
options?: UseQueryOptions<
|
||||
TSecretApprovalPolicy[],
|
||||
unknown,
|
||||
TSecretApprovalPolicy[],
|
||||
ReturnType<typeof secretApprovalKeys.getApprovalPolicies>
|
||||
>;
|
||||
}) =>
|
||||
}: TGetSecretApprovalPoliciesDTO & TReactQueryOptions) =>
|
||||
useQuery({
|
||||
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId),
|
||||
queryFn: () => fetchApprovalPolicies(workspaceId),
|
||||
@@ -60,14 +54,7 @@ export const useGetSecretApprovalPolicyOfABoard = ({
|
||||
secretPath = "/",
|
||||
environment,
|
||||
options = {}
|
||||
}: TGetSecretApprovalPolicyOfBoardDTO & {
|
||||
options?: UseQueryOptions<
|
||||
TSecretApprovalPolicy,
|
||||
unknown,
|
||||
TSecretApprovalPolicy,
|
||||
ReturnType<typeof secretApprovalKeys.getApprovalPolicyOfABoard>
|
||||
>;
|
||||
}) =>
|
||||
}: TGetSecretApprovalPolicyOfBoardDTO & TReactQueryOptions) =>
|
||||
useQuery({
|
||||
queryKey: secretApprovalKeys.getApprovalPolicyOfABoard(workspaceId, environment, secretPath),
|
||||
queryFn: () => fetchApprovalPolicyOfABoard(workspaceId, environment, secretPath),
|
||||
|
||||
@@ -14,15 +14,15 @@ export type TSecretApprovalPolicy = {
|
||||
enforcementLevel: EnforcementLevel;
|
||||
};
|
||||
|
||||
export enum ApproverType{
|
||||
export enum ApproverType {
|
||||
User = "user",
|
||||
Group = "group"
|
||||
}
|
||||
|
||||
export type Approver ={
|
||||
export type Approver = {
|
||||
id: string;
|
||||
type: ApproverType;
|
||||
}
|
||||
};
|
||||
|
||||
export type TGetSecretApprovalPoliciesDTO = {
|
||||
workspaceId: string;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
export const useUpdateSecretApprovalReviewStatus = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretApprovalReviewStatusDTO>({
|
||||
return useMutation<object, object, TUpdateSecretApprovalReviewStatusDTO>({
|
||||
mutationFn: async ({ id, status }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/review`, {
|
||||
status
|
||||
@@ -20,7 +20,7 @@ export const useUpdateSecretApprovalReviewStatus = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { id }) => {
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.detail({ id }));
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -28,7 +28,7 @@ export const useUpdateSecretApprovalReviewStatus = () => {
|
||||
export const useUpdateSecretApprovalRequestStatus = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretApprovalRequestStatusDTO>({
|
||||
return useMutation<object, object, TUpdateSecretApprovalRequestStatusDTO>({
|
||||
mutationFn: async ({ id, status }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/status`, {
|
||||
status
|
||||
@@ -36,8 +36,8 @@ export const useUpdateSecretApprovalRequestStatus = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { id, workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.detail({ id }));
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -45,7 +45,7 @@ export const useUpdateSecretApprovalRequestStatus = () => {
|
||||
export const usePerformSecretApprovalRequestMerge = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TPerformSecretApprovalRequestMerge>({
|
||||
return useMutation<object, object, TPerformSecretApprovalRequestMerge>({
|
||||
mutationFn: async ({ id, bypassReason }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/merge`, {
|
||||
bypassReason
|
||||
@@ -53,9 +53,9 @@ export const usePerformSecretApprovalRequestMerge = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { id, workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.detail({ id }));
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.list({ workspaceId }));
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.list({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
import {
|
||||
useInfiniteQuery,
|
||||
UseInfiniteQueryOptions,
|
||||
useQuery,
|
||||
UseQueryOptions
|
||||
} from "@tanstack/react-query";
|
||||
import { useInfiniteQuery, useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import {
|
||||
decryptAssymmetric,
|
||||
decryptSymmetric
|
||||
} from "@app/components/utilities/cryptography/crypto";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import { UserWsKeyPair } from "../keys/types";
|
||||
import { EncryptedSecret, SecretType, SecretV3RawSanitized } from "../secrets/types";
|
||||
@@ -147,18 +143,9 @@ export const useGetSecretApprovalRequests = ({
|
||||
status,
|
||||
limit = 20,
|
||||
committer
|
||||
}: TGetSecretApprovalRequestList & {
|
||||
options?: Omit<
|
||||
UseInfiniteQueryOptions<
|
||||
TSecretApprovalRequest[],
|
||||
unknown,
|
||||
TSecretApprovalRequest[],
|
||||
ReturnType<typeof secretApprovalRequestKeys.list>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>;
|
||||
}) =>
|
||||
}: TGetSecretApprovalRequestList & TReactQueryOptions) =>
|
||||
useInfiniteQuery({
|
||||
initialPageParam: 0,
|
||||
queryKey: secretApprovalRequestKeys.list({
|
||||
workspaceId,
|
||||
environment,
|
||||
|
||||
@@ -116,7 +116,7 @@ export const useGetFoldersByEnv = ({
|
||||
export const useCreateFolder = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateFolderDTO>({
|
||||
return useMutation<object, object, TCreateFolderDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/folders", {
|
||||
...dto,
|
||||
@@ -125,21 +125,21 @@ export const useCreateFolder = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId, environment, path }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({
|
||||
projectId,
|
||||
secretPath: path ?? "/"
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
folderQueryKeys.getSecretFolders({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
|
||||
);
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -147,7 +147,7 @@ export const useCreateFolder = () => {
|
||||
export const useUpdateFolder = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateFolderDTO>({
|
||||
return useMutation<object, object, TUpdateFolderDTO>({
|
||||
mutationFn: async ({ path = "/", folderId, name, environment, projectId }) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/folders/${folderId}`, {
|
||||
name,
|
||||
@@ -158,21 +158,21 @@ export const useUpdateFolder = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId, environment, path }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({
|
||||
projectId,
|
||||
secretPath: path ?? "/"
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
folderQueryKeys.getSecretFolders({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
|
||||
);
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -180,7 +180,7 @@ export const useUpdateFolder = () => {
|
||||
export const useDeleteFolder = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteFolderDTO>({
|
||||
return useMutation<object, object, TDeleteFolderDTO>({
|
||||
mutationFn: async ({ path = "/", folderId, environment, projectId }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/folders/${folderId}`, {
|
||||
data: {
|
||||
@@ -192,21 +192,21 @@ export const useDeleteFolder = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { path = "/", projectId, environment }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({
|
||||
projectId,
|
||||
secretPath: path
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
folderQueryKeys.getSecretFolders({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
|
||||
);
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -214,7 +214,7 @@ export const useDeleteFolder = () => {
|
||||
export const useUpdateFolderBatch = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateFolderBatchDTO>({
|
||||
return useMutation<object, object, TUpdateFolderBatchDTO>({
|
||||
mutationFn: async ({ projectSlug, folders }) => {
|
||||
const { data } = await apiRequest.patch("/api/v1/folders/batch", {
|
||||
projectSlug,
|
||||
@@ -225,33 +225,33 @@ export const useUpdateFolderBatch = () => {
|
||||
},
|
||||
onSuccess: (_, { projectId, folders }) => {
|
||||
folders.forEach((folder) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({
|
||||
projectId,
|
||||
secretPath: folder.path ?? "/"
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
folderQueryKeys.getSecretFolders({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: folderQueryKeys.getSecretFolders({
|
||||
projectId,
|
||||
environment: folder.environment,
|
||||
path: folder.path
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({
|
||||
workspaceId: projectId,
|
||||
environment: folder.environment,
|
||||
directory: folder.path
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({
|
||||
workspaceId: projectId,
|
||||
environment: folder.environment,
|
||||
directory: folder.path
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
export const useCreateSecretImport = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretImportDTO>({
|
||||
return useMutation<object, object, TCreateSecretImportDTO>({
|
||||
mutationFn: async ({ import: secretImport, environment, isReplication, projectId, path }) => {
|
||||
const { data } = await apiRequest.post("/api/v1/secret-imports", {
|
||||
import: secretImport,
|
||||
@@ -26,15 +26,15 @@ export const useCreateSecretImport = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { environment, projectId, path }) => {
|
||||
queryClient.invalidateQueries(
|
||||
secretImportKeys.getProjectSecretImports({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretImportKeys.getSecretImportSecrets({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId, secretPath: path ?? "/" })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretImportKeys.getProjectSecretImports({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretImportKeys.getSecretImportSecrets({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath: path ?? "/" })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -42,7 +42,7 @@ export const useCreateSecretImport = () => {
|
||||
export const useUpdateSecretImport = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretImportDTO>({
|
||||
return useMutation<object, object, TUpdateSecretImportDTO>({
|
||||
mutationFn: async ({ environment, import: secretImports, projectId, path, id }) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/secret-imports/${id}`, {
|
||||
import: secretImports,
|
||||
@@ -53,21 +53,21 @@ export const useUpdateSecretImport = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { environment, projectId, path }) => {
|
||||
queryClient.invalidateQueries(
|
||||
secretImportKeys.getProjectSecretImports({ projectId, path, environment })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretImportKeys.getSecretImportSecrets({ environment, path, projectId })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId, secretPath: path ?? "/" })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretImportKeys.getProjectSecretImports({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretImportKeys.getSecretImportSecrets({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath: path ?? "/" })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useResyncSecretReplication = () => {
|
||||
return useMutation<{}, {}, TResyncSecretReplicationDTO>({
|
||||
return useMutation<object, object, TResyncSecretReplicationDTO>({
|
||||
mutationFn: async ({ environment, projectId, path, id }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-imports/${id}/replication-resync`, {
|
||||
environment,
|
||||
@@ -82,7 +82,7 @@ export const useResyncSecretReplication = () => {
|
||||
export const useDeleteSecretImport = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretImportDTO>({
|
||||
return useMutation<object, object, TDeleteSecretImportDTO>({
|
||||
mutationFn: async ({ id, projectId, path, environment }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/secret-imports/${id}`, {
|
||||
data: {
|
||||
@@ -94,15 +94,15 @@ export const useDeleteSecretImport = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId, environment, path }) => {
|
||||
queryClient.invalidateQueries(
|
||||
secretImportKeys.getProjectSecretImports({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretImportKeys.getSecretImportSecrets({ projectId, environment, path })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId, secretPath: path ?? "/" })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretImportKeys.getProjectSecretImports({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretImportKeys.getSecretImportSecrets({ projectId, environment, path })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath: path ?? "/" })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,13 +12,13 @@ import {
|
||||
export const useCreateSecretRotation = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretRotationDTO>({
|
||||
return useMutation<object, object, TCreateSecretRotationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/secret-rotations", dto);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretRotationKeys.list({ workspaceId }));
|
||||
queryClient.invalidateQueries({ queryKey: secretRotationKeys.list({ workspaceId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -26,13 +26,13 @@ export const useCreateSecretRotation = () => {
|
||||
export const useDeleteSecretRotation = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretRotationDTO>({
|
||||
return useMutation<object, object, TDeleteSecretRotationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/secret-rotations/${dto.id}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretRotationKeys.list({ workspaceId }));
|
||||
queryClient.invalidateQueries({ queryKey: secretRotationKeys.list({ workspaceId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -40,13 +40,13 @@ export const useDeleteSecretRotation = () => {
|
||||
export const useRestartSecretRotation = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TRestartSecretRotationDTO>({
|
||||
return useMutation<object, object, TRestartSecretRotationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/secret-rotations/restart", { id: dto.id });
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(secretRotationKeys.list({ workspaceId }));
|
||||
queryClient.invalidateQueries({ queryKey: secretRotationKeys.list({ workspaceId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
export {
|
||||
useCreateNewInstallationSession,
|
||||
useLinkGitAppInstallationWithOrg,
|
||||
useUpdateRiskStatus
|
||||
} from "./mutation";
|
||||
export {
|
||||
secretScanningQueryKeys,
|
||||
useGetSecretScanningInstallationStatus,
|
||||
useGetSecretScanningRisks
|
||||
} from "./queries";
|
||||
@@ -0,0 +1,45 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { RiskStatus, TGitAppOrg, TSecretScanningGitRisks } from "./types";
|
||||
|
||||
export const useCreateNewInstallationSession = () => {
|
||||
return useMutation<{ sessionId: string }, object, { organizationId: string }>({
|
||||
mutationFn: async (opt) => {
|
||||
const { data } = await apiRequest.post(
|
||||
"/api/v1/secret-scanning/create-installation-session/organization",
|
||||
opt
|
||||
);
|
||||
return data;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateRiskStatus = () => {
|
||||
return useMutation<
|
||||
TSecretScanningGitRisks,
|
||||
object,
|
||||
{ organizationId: string; riskId: string; status: RiskStatus }
|
||||
>({
|
||||
mutationFn: async (opt) => {
|
||||
const { data } = await apiRequest.post<TSecretScanningGitRisks>(
|
||||
`/api/v1/secret-scanning/organization/${opt.organizationId}/risks/${opt.riskId}/status`,
|
||||
{ status: opt.status }
|
||||
);
|
||||
return data;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useLinkGitAppInstallationWithOrg = () => {
|
||||
return useMutation<TGitAppOrg, object, { sessionId: string; installationId: string }>({
|
||||
mutationFn: async (opt) => {
|
||||
const { data } = await apiRequest.post<TGitAppOrg>(
|
||||
"/api/v1/secret-scanning/link-installation",
|
||||
opt
|
||||
);
|
||||
return data;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { TSecretScanningGitRisks } from "./types";
|
||||
|
||||
export const secretScanningQueryKeys = {
|
||||
getInstallationStatus: (orgId: string) => ["secret-scanning-installation-status", { orgId }],
|
||||
getRisksByOrganizatio: (orgId: string) => ["secret-scanning-risks", { orgId }]
|
||||
};
|
||||
|
||||
const fetchSecretScanningInstallationStatus = async (organizationId: string) => {
|
||||
const { data } = await apiRequest.get<{ appInstallationCompleted: boolean }>(
|
||||
`/api/v1/secret-scanning/installation-status/organization/${organizationId}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const useGetSecretScanningInstallationStatus = (orgId: string) =>
|
||||
useQuery({
|
||||
queryKey: secretScanningQueryKeys.getInstallationStatus(orgId),
|
||||
queryFn: () => fetchSecretScanningInstallationStatus(orgId)
|
||||
});
|
||||
|
||||
const fetchSecretScanningRisksByOrgId = async (oranizationId: string) => {
|
||||
const { data } = await apiRequest.get<{ risks: TSecretScanningGitRisks[] }>(
|
||||
`/api/v1/secret-scanning/organization/${oranizationId}/risks`
|
||||
);
|
||||
return data.risks;
|
||||
};
|
||||
|
||||
export const useGetSecretScanningRisks = (orgId: string) =>
|
||||
useQuery({
|
||||
queryKey: secretScanningQueryKeys.getRisksByOrganizatio(orgId),
|
||||
queryFn: () => fetchSecretScanningRisksByOrgId(orgId)
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
export enum RiskStatus {
|
||||
RESOLVED_FALSE_POSITIVE = "RESOLVED_FALSE_POSITIVE",
|
||||
RESOLVED_REVOKED = "RESOLVED_REVOKED",
|
||||
RESOLVED_NOT_REVOKED = "RESOLVED_NOT_REVOKED",
|
||||
UNRESOLVED = "UNRESOLVED"
|
||||
}
|
||||
|
||||
export type TSecretScanningGitRisks = {
|
||||
id: string;
|
||||
description: string;
|
||||
startLine: string;
|
||||
endLine: string;
|
||||
startColumn: string;
|
||||
endColumn: string;
|
||||
match: string;
|
||||
secret: string;
|
||||
file: string;
|
||||
symlinkFile: string;
|
||||
commit: string;
|
||||
entropy: string;
|
||||
author: string;
|
||||
email: string;
|
||||
date: string;
|
||||
message: string;
|
||||
tags: string[];
|
||||
ruleID: string;
|
||||
fingerprint: string;
|
||||
status: string;
|
||||
isFalsePositive: boolean; // New field for marking risks as false positives
|
||||
isResolved: boolean; // New field for marking risks as resolved
|
||||
riskOwner: string | null; // New field for setting a risk owner (nullable string)
|
||||
installationId: string;
|
||||
repositoryId: string;
|
||||
repositoryLink: string;
|
||||
repositoryFullName: string;
|
||||
pusher: {
|
||||
name: string;
|
||||
email: string;
|
||||
};
|
||||
createdAt: string;
|
||||
orgId: string;
|
||||
};
|
||||
|
||||
export type TGitAppOrg = {
|
||||
id: string;
|
||||
installationId: string;
|
||||
userId: string;
|
||||
orgId: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
};
|
||||
@@ -20,7 +20,8 @@ export const useCreateSharedSecret = () => {
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries(secretSharingKeys.allSharedSecrets())
|
||||
onSuccess: () =>
|
||||
queryClient.invalidateQueries({ queryKey: secretSharingKeys.allSharedSecrets() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -34,7 +35,8 @@ export const useCreatePublicSharedSecret = () => {
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries(secretSharingKeys.allSharedSecrets())
|
||||
onSuccess: () =>
|
||||
queryClient.invalidateQueries({ queryKey: secretSharingKeys.allSharedSecrets() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,6 +49,7 @@ export const useDeleteSharedSecret = () => {
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => queryClient.invalidateQueries(secretSharingKeys.allSharedSecrets())
|
||||
onSuccess: () =>
|
||||
queryClient.invalidateQueries({ queryKey: secretSharingKeys.allSharedSecrets() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -49,9 +49,9 @@ export const useGetActiveSharedSecretById = ({
|
||||
hashedHex: string | null;
|
||||
password?: string;
|
||||
}) => {
|
||||
return useQuery<TViewSharedSecretResponse>(
|
||||
secretSharingKeys.getSecretById({ id: sharedSecretId, hashedHex, password }),
|
||||
async () => {
|
||||
return useQuery({
|
||||
queryKey: secretSharingKeys.getSecretById({ id: sharedSecretId, hashedHex, password }),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.post<TViewSharedSecretResponse>(
|
||||
`/api/v1/secret-sharing/public/${sharedSecretId}`,
|
||||
{
|
||||
@@ -62,8 +62,6 @@ export const useGetActiveSharedSecretById = ({
|
||||
|
||||
return data;
|
||||
},
|
||||
{
|
||||
enabled: Boolean(sharedSecretId)
|
||||
}
|
||||
);
|
||||
enabled: Boolean(sharedSecretId)
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,6 +47,7 @@ const fetchWorkspaceSnaphots = async ({
|
||||
|
||||
export const useGetWorkspaceSnapshotList = (dto: TGetSecretSnapshotsDTO & { isPaused?: boolean }) =>
|
||||
useInfiniteQuery({
|
||||
initialPageParam: 0,
|
||||
enabled: Boolean(dto.workspaceId && dto.environment) && !dto.isPaused,
|
||||
queryKey: secretSnapshotKeys.list({ ...dto }),
|
||||
queryFn: ({ pageParam }) => fetchWorkspaceSnaphots({ ...dto, offset: pageParam }),
|
||||
@@ -142,26 +143,24 @@ export const useGetWsSnapshotCount = ({
|
||||
export const usePerformSecretRollback = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TSecretRollbackDTO>({
|
||||
return useMutation<object, object, TSecretRollbackDTO>({
|
||||
mutationFn: async ({ snapshotId }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/secret-snapshot/${snapshotId}/rollback`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, directory }) => {
|
||||
queryClient.invalidateQueries([
|
||||
{ workspaceId, environment, secretPath: directory },
|
||||
"secrets"
|
||||
]);
|
||||
queryClient.invalidateQueries([
|
||||
"secret-folders",
|
||||
{ projectId: workspaceId, environment, path: directory }
|
||||
]);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ workspaceId, environment, directory })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ workspaceId, environment, directory })
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [{ workspaceId, environment, secretPath: directory }, "secrets"]
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["secret-folders", { projectId: workspaceId, environment, path: directory }]
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ workspaceId, environment, directory })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory })
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,4 +12,5 @@ export {
|
||||
useGetProjectSecrets,
|
||||
useGetProjectSecretsAllEnv,
|
||||
useGetSecretReferenceTree,
|
||||
useGetSecretVersion} from "./queries";
|
||||
useGetSecretVersion
|
||||
} from "./queries";
|
||||
|
||||
@@ -19,10 +19,10 @@ import {
|
||||
export const useCreateSecretV3 = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TCreateSecretsV3DTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TCreateSecretsV3DTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, TCreateSecretsV3DTO>({
|
||||
return useMutation<object, object, TCreateSecretsV3DTO>({
|
||||
mutationFn: async ({
|
||||
secretPath = "/",
|
||||
type,
|
||||
@@ -47,19 +47,19 @@ export const useCreateSecretV3 = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -68,10 +68,10 @@ export const useCreateSecretV3 = ({
|
||||
export const useUpdateSecretV3 = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TUpdateSecretsV3DTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TUpdateSecretsV3DTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, TUpdateSecretsV3DTO>({
|
||||
return useMutation<object, object, TUpdateSecretsV3DTO>({
|
||||
mutationFn: async ({
|
||||
secretPath = "/",
|
||||
type,
|
||||
@@ -104,19 +104,19 @@ export const useUpdateSecretV3 = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -125,11 +125,11 @@ export const useUpdateSecretV3 = ({
|
||||
export const useDeleteSecretV3 = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TDeleteSecretsV3DTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TDeleteSecretsV3DTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretsV3DTO>({
|
||||
return useMutation<object, object, TDeleteSecretsV3DTO>({
|
||||
mutationFn: async ({
|
||||
secretPath = "/",
|
||||
type,
|
||||
@@ -150,19 +150,19 @@ export const useDeleteSecretV3 = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -171,11 +171,11 @@ export const useDeleteSecretV3 = ({
|
||||
export const useCreateSecretBatch = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TCreateSecretBatchDTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TCreateSecretBatchDTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretBatchDTO>({
|
||||
return useMutation<object, object, TCreateSecretBatchDTO>({
|
||||
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.post("/api/v3/secrets/batch/raw", {
|
||||
workspaceId,
|
||||
@@ -186,19 +186,19 @@ export const useCreateSecretBatch = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -207,11 +207,11 @@ export const useCreateSecretBatch = ({
|
||||
export const useUpdateSecretBatch = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TUpdateSecretBatchDTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TUpdateSecretBatchDTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretBatchDTO>({
|
||||
return useMutation<object, object, TUpdateSecretBatchDTO>({
|
||||
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.patch("/api/v3/secrets/batch/raw", {
|
||||
workspaceId,
|
||||
@@ -222,19 +222,19 @@ export const useUpdateSecretBatch = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -243,11 +243,11 @@ export const useUpdateSecretBatch = ({
|
||||
export const useDeleteSecretBatch = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TDeleteSecretBatchDTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TDeleteSecretBatchDTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSecretBatchDTO>({
|
||||
return useMutation<object, object, TDeleteSecretBatchDTO>({
|
||||
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.delete("/api/v3/secrets/batch/raw", {
|
||||
data: {
|
||||
@@ -260,19 +260,19 @@ export const useDeleteSecretBatch = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId }));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -281,7 +281,7 @@ export const useDeleteSecretBatch = ({
|
||||
export const useMoveSecrets = ({
|
||||
options
|
||||
}: {
|
||||
options?: Omit<MutationOptions<{}, {}, TMoveSecretsDTO>, "mutationFn">;
|
||||
options?: Omit<MutationOptions<object, object, TMoveSecretsDTO>, "mutationFn">;
|
||||
} = {}) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -290,7 +290,7 @@ export const useMoveSecrets = ({
|
||||
isSourceUpdated: boolean;
|
||||
isDestinationUpdated: boolean;
|
||||
},
|
||||
{},
|
||||
object,
|
||||
TMoveSecretsDTO
|
||||
>({
|
||||
mutationFn: async ({
|
||||
@@ -318,34 +318,36 @@ export const useMoveSecrets = ({
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId, sourceEnvironment, sourceSecretPath }) => {
|
||||
queryClient.invalidateQueries(
|
||||
dashboardKeys.getDashboardSecrets({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({
|
||||
projectId,
|
||||
secretPath: sourceSecretPath
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretKeys.getProjectSecret({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({
|
||||
workspaceId: projectId,
|
||||
environment: sourceEnvironment,
|
||||
secretPath: sourceSecretPath
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.list({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({
|
||||
environment: sourceEnvironment,
|
||||
workspaceId: projectId,
|
||||
directory: sourceSecretPath
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(
|
||||
secretSnapshotKeys.count({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({
|
||||
environment: sourceEnvironment,
|
||||
workspaceId: projectId,
|
||||
directory: sourceSecretPath
|
||||
})
|
||||
);
|
||||
queryClient.invalidateQueries(secretApprovalRequestKeys.count({ workspaceId: projectId }));
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretApprovalRequestKeys.count({ workspaceId: projectId })
|
||||
});
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -357,7 +359,7 @@ export const createSecret = async (dto: TCreateSecretsV3DTO) => {
|
||||
};
|
||||
|
||||
export const useBackfillSecretReference = () =>
|
||||
useMutation<{ message: string }, {}, { projectId: string }>({
|
||||
useMutation<{ message: string }, object, { projectId: string }>({
|
||||
mutationFn: async ({ projectId }) => {
|
||||
const { data } = await apiRequest.post("/api/v3/secrets/backfill-secret-references", {
|
||||
projectId
|
||||
|
||||
@@ -116,26 +116,6 @@ export const useGetProjectSecrets = ({
|
||||
enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true),
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }),
|
||||
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath }),
|
||||
onError: (error) => {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const { message, requestId } = error.response?.data as {
|
||||
message: string;
|
||||
requestId: string;
|
||||
};
|
||||
createNotification({
|
||||
title: "Error fetching secrets",
|
||||
type: "error",
|
||||
text: message,
|
||||
copyActions: [
|
||||
{
|
||||
value: requestId,
|
||||
name: "Request ID",
|
||||
label: `Request ID: ${requestId}`
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
},
|
||||
select: useCallback(
|
||||
(data: Awaited<ReturnType<typeof fetchProjectSecrets>>) => mergePersonalSecrets(data.secrets),
|
||||
[]
|
||||
|
||||
@@ -36,14 +36,16 @@ export const useCreateServiceToken = () => {
|
||||
// TODO: deprecate
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<CreateServiceTokenRes, {}, CreateServiceTokenDTO>({
|
||||
return useMutation<CreateServiceTokenRes, object, CreateServiceTokenDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post("/api/v2/service-token/", body);
|
||||
data.serviceToken += `.${body.randomBytes}`;
|
||||
return data;
|
||||
},
|
||||
onSuccess: ({ serviceTokenData: { projectId } }) => {
|
||||
queryClient.invalidateQueries(serviceTokenKeys.getAllWorkspaceServiceToken(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: serviceTokenKeys.getAllWorkspaceServiceToken(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -51,13 +53,15 @@ export const useCreateServiceToken = () => {
|
||||
export const useDeleteServiceToken = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<DeleteServiceTokenRes, {}, string>({
|
||||
return useMutation<DeleteServiceTokenRes, object, string>({
|
||||
mutationFn: async (serviceTokenId) => {
|
||||
const { data } = await apiRequest.delete(`/api/v2/service-token/${serviceTokenId}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: ({ serviceTokenData: { projectId } }) => {
|
||||
queryClient.invalidateQueries(serviceTokenKeys.getAllWorkspaceServiceToken(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: serviceTokenKeys.getAllWorkspaceServiceToken(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
+15
-11
@@ -20,7 +20,7 @@ export const sshCaKeys = {
|
||||
|
||||
export const useCreateSshCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSshCertificateAuthority, {}, TCreateSshCaDTO>({
|
||||
return useMutation<TSshCertificateAuthority, object, TCreateSshCaDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const {
|
||||
data: { ca }
|
||||
@@ -28,14 +28,14 @@ export const useCreateSshCa = () => {
|
||||
return ca;
|
||||
},
|
||||
onSuccess: ({ projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceSshCas(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateSshCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSshCertificateAuthority, {}, TUpdateSshCaDTO>({
|
||||
return useMutation<TSshCertificateAuthority, object, TUpdateSshCaDTO>({
|
||||
mutationFn: async ({ caId, ...body }) => {
|
||||
const {
|
||||
data: { ca }
|
||||
@@ -43,15 +43,15 @@ export const useUpdateSshCa = () => {
|
||||
return ca;
|
||||
},
|
||||
onSuccess: ({ projectId }, { caId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceSshCas(projectId));
|
||||
queryClient.invalidateQueries(sshCaKeys.getSshCaById(caId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaById(caId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteSshCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSshCertificateAuthority, {}, TDeleteSshCaDTO>({
|
||||
return useMutation<TSshCertificateAuthority, object, TDeleteSshCaDTO>({
|
||||
mutationFn: async ({ caId }) => {
|
||||
const {
|
||||
data: { ca }
|
||||
@@ -59,14 +59,14 @@ export const useDeleteSshCa = () => {
|
||||
return ca;
|
||||
},
|
||||
onSuccess: ({ projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceSshCas(projectId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useSignSshKey = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSignSshKeyResponse, {}, TSignSshKeyDTO>({
|
||||
return useMutation<TSignSshKeyResponse, object, TSignSshKeyDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TSignSshKeyResponse>(
|
||||
"/api/v1/ssh/certificates/sign",
|
||||
@@ -75,14 +75,16 @@ export const useSignSshKey = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.allWorkspaceSshCertificates(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useIssueSshCreds = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TIssueSshCredsResponse, {}, TIssueSshCredsDTO>({
|
||||
return useMutation<TIssueSshCredsResponse, object, TIssueSshCredsDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TIssueSshCredsResponse>(
|
||||
"/api/v1/ssh/certificates/issue",
|
||||
@@ -91,7 +93,9 @@ export const useIssueSshCreds = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.allWorkspaceSshCertificates(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { sshCaKeys } from "../ssh-ca/queries";
|
||||
import { sshCaKeys } from "../sshCa/queries";
|
||||
import {
|
||||
TCreateSshCertificateTemplateDTO,
|
||||
TDeleteSshCertificateTemplateDTO,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
|
||||
export const useCreateSshCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSshCertificateTemplate, {}, TCreateSshCertificateTemplateDTO>({
|
||||
return useMutation<TSshCertificateTemplate, object, TCreateSshCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
const { data: certificateTemplate } = await apiRequest.post<TSshCertificateTemplate>(
|
||||
"/api/v1/ssh/certificate-templates",
|
||||
@@ -21,14 +21,14 @@ export const useCreateSshCertTemplate = () => {
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: ({ sshCaId }) => {
|
||||
queryClient.invalidateQueries(sshCaKeys.getSshCaCertTemplates(sshCaId));
|
||||
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaCertTemplates(sshCaId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateSshCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSshCertificateTemplate, {}, TUpdateSshCertificateTemplateDTO>({
|
||||
return useMutation<TSshCertificateTemplate, object, TUpdateSshCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
const { data: certificateTemplate } = await apiRequest.patch<TSshCertificateTemplate>(
|
||||
`/api/v1/ssh/certificate-templates/${data.id}`,
|
||||
@@ -38,14 +38,14 @@ export const useUpdateSshCertTemplate = () => {
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: ({ sshCaId }) => {
|
||||
queryClient.invalidateQueries(sshCaKeys.getSshCaCertTemplates(sshCaId));
|
||||
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaCertTemplates(sshCaId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteSshCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSshCertificateTemplate, {}, TDeleteSshCertificateTemplateDTO>({
|
||||
return useMutation<TSshCertificateTemplate, object, TDeleteSshCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
const { data: certificateTemplate } = await apiRequest.delete<TSshCertificateTemplate>(
|
||||
`/api/v1/ssh/certificate-templates/${data.id}`
|
||||
@@ -53,7 +53,7 @@ export const useDeleteSshCertTemplate = () => {
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: ({ sshCaId }) => {
|
||||
queryClient.invalidateQueries(sshCaKeys.getSshCaCertTemplates(sshCaId));
|
||||
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaCertTemplates(sshCaId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export const useGetSSOConfig = (organizationId: string) => {
|
||||
);
|
||||
|
||||
return data;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
@@ -55,7 +55,7 @@ export const useCreateSSOConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(ssoConfigKeys.getSSOConfig(dto.organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: ssoConfigKeys.getSSOConfig(dto.organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -91,10 +91,10 @@ export const useUpdateSSOConfig = () => {
|
||||
},
|
||||
onSuccess(_, { organizationId, isActive }) {
|
||||
if (isActive === false) {
|
||||
queryClient.invalidateQueries(organizationKeys.getUserOrganizations);
|
||||
queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
|
||||
}
|
||||
|
||||
queryClient.invalidateQueries(ssoConfigKeys.getSSOConfig(organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: ssoConfigKeys.getSSOConfig(organizationId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,11 +6,11 @@ import { SubscriptionPlan } from "./types";
|
||||
|
||||
// import { Workspace } from './types';
|
||||
|
||||
const subscriptionKeys = {
|
||||
export const subscriptionQueryKeys = {
|
||||
getOrgSubsription: (orgID: string) => ["plan", { orgID }] as const
|
||||
};
|
||||
|
||||
const fetchOrgSubscription = async (orgID: string) => {
|
||||
export const fetchOrgSubscription = async (orgID: string) => {
|
||||
const { data } = await apiRequest.get<{ plan: SubscriptionPlan }>(
|
||||
`/api/v1/organizations/${orgID}/plan`
|
||||
);
|
||||
@@ -24,7 +24,7 @@ type UseGetOrgSubscriptionProps = {
|
||||
|
||||
export const useGetOrgSubscription = ({ orgID }: UseGetOrgSubscriptionProps) =>
|
||||
useQuery({
|
||||
queryKey: subscriptionKeys.getOrgSubsription(orgID),
|
||||
queryKey: subscriptionQueryKeys.getOrgSubsription(orgID),
|
||||
queryFn: () => fetchOrgSubscription(orgID),
|
||||
enabled: Boolean(orgID)
|
||||
});
|
||||
|
||||
@@ -45,5 +45,5 @@ export type SubscriptionPlan = {
|
||||
pkiEst: boolean;
|
||||
enforceMfa: boolean;
|
||||
projectTemplates: boolean;
|
||||
appConnections: boolean; // TODO: remove once released
|
||||
appConnections: boolean;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ export const useGetWsTags = (workspaceID: string) => {
|
||||
export const useCreateWsTag = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<WsTag, {}, CreateTagDTO>({
|
||||
return useMutation<WsTag, object, CreateTagDTO>({
|
||||
mutationFn: async ({ workspaceID, tagColor, tagSlug }) => {
|
||||
const { data } = await apiRequest.post<{ workspaceTag: WsTag }>(
|
||||
`/api/v1/workspace/${workspaceID}/tags`,
|
||||
@@ -39,7 +39,7 @@ export const useCreateWsTag = () => {
|
||||
return data.workspaceTag;
|
||||
},
|
||||
onSuccess: (tagData) => {
|
||||
queryClient.invalidateQueries(workspaceTags.getWsTags(tagData?.projectId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceTags.getWsTags(tagData?.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -47,7 +47,7 @@ export const useCreateWsTag = () => {
|
||||
export const useDeleteWsTag = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<WsTag, {}, DeleteTagDTO>({
|
||||
return useMutation<WsTag, object, DeleteTagDTO>({
|
||||
mutationFn: async ({ tagID, projectId }) => {
|
||||
const { data } = await apiRequest.delete<{ workspaceTag: WsTag }>(
|
||||
`/api/v1/workspace/${projectId}/tags/${tagID}`
|
||||
@@ -55,7 +55,7 @@ export const useDeleteWsTag = () => {
|
||||
return data.workspaceTag;
|
||||
},
|
||||
onSuccess: (tagData) => {
|
||||
queryClient.invalidateQueries(workspaceTags.getWsTags(tagData?.projectId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceTags.getWsTags(tagData?.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ export const useAddTrustedIp = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(trustedIps.getTrustedIps(dto.workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -77,7 +77,7 @@ export const useUpdateTrustedIp = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(trustedIps.getTrustedIps(dto.workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -99,7 +99,7 @@ export const useDeleteTrustedIp = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries(trustedIps.getTrustedIps(dto.workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import { apiRequest } from "@app/config/request";
|
||||
import { TCreateUserWishDto } from "./types";
|
||||
|
||||
export const useCreateUserWish = () => {
|
||||
return useMutation<{}, {}, TCreateUserWishDto>({
|
||||
return useMutation<object, object, TCreateUserWishDto>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/user-engagement/me/wish", dto);
|
||||
return data;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { AddUserToWsDTOE2EE, AddUserToWsDTONonE2EE } from "./types";
|
||||
export const useAddUserToWsE2EE = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, AddUserToWsDTOE2EE>({
|
||||
return useMutation<object, object, AddUserToWsDTOE2EE>({
|
||||
mutationFn: async ({ workspaceId, members, decryptKey, userPrivateKey }) => {
|
||||
// assymmetrically decrypt symmetric key with local private key
|
||||
const key = decryptAssymmetric({
|
||||
@@ -42,7 +42,7 @@ export const useAddUserToWsE2EE = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -50,7 +50,7 @@ export const useAddUserToWsE2EE = () => {
|
||||
export const useAddUserToWsNonE2EE = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, AddUserToWsDTONonE2EE>({
|
||||
return useMutation<object, object, AddUserToWsDTONonE2EE>({
|
||||
mutationFn: async ({ projectId, usernames, roleSlugs }) => {
|
||||
const { data } = await apiRequest.post(`/api/v2/workspace/${projectId}/memberships`, {
|
||||
usernames,
|
||||
@@ -59,8 +59,10 @@ export const useAddUserToWsNonE2EE = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId, projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(projectId));
|
||||
queryClient.invalidateQueries(userKeys.allOrgMembershipProjectMemberships(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(projectId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -110,7 +112,7 @@ export const useUpdateUserProjectFavorites = () => {
|
||||
return {};
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(userKeys.userProjectFavorites(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.userProjectFavorites(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -136,7 +138,7 @@ export const useDeleteUserTotpConfiguration = () => {
|
||||
return {};
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.totpConfiguration);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.totpConfiguration });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -150,7 +152,7 @@ export const useCreateNewTotpRecoveryCodes = () => {
|
||||
return {};
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.totpConfiguration);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.totpConfiguration });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,11 +3,11 @@ import { AxiosError } from "axios";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { SessionStorageKeys } from "@app/const";
|
||||
import { setAuthToken } from "@app/reactQuery";
|
||||
|
||||
import { APIKeyDataV2 } from "../apiKeys/types";
|
||||
import { MfaMethod } from "../auth/types";
|
||||
import { TGroupWithProjectMemberships } from "../groups/types";
|
||||
import { setAuthToken } from "../reactQuery";
|
||||
import { workspaceKeys } from "../workspace";
|
||||
import { userKeys } from "./query-keys";
|
||||
import {
|
||||
@@ -31,7 +31,11 @@ export const fetchUserDetails = async () => {
|
||||
return data.user;
|
||||
};
|
||||
|
||||
export const useGetUser = () => useQuery(userKeys.getUser, fetchUserDetails);
|
||||
export const useGetUser = () =>
|
||||
useQuery({
|
||||
queryKey: userKeys.getUser,
|
||||
queryFn: fetchUserDetails
|
||||
});
|
||||
|
||||
export const useDeleteMe = () => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -53,7 +57,6 @@ export const useDeleteMe = () => {
|
||||
localStorage.removeItem("tag");
|
||||
localStorage.removeItem("PRIVATE_KEY");
|
||||
localStorage.removeItem("orgData.id");
|
||||
localStorage.removeItem("projectData.id");
|
||||
|
||||
queryClient.clear();
|
||||
}
|
||||
@@ -80,14 +83,14 @@ export const fetchUserProjectFavorites = async (orgId: string) => {
|
||||
export const useRenameUser = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, RenameUserDTO>({
|
||||
return useMutation<object, object, RenameUserDTO>({
|
||||
mutationFn: ({ newName }) =>
|
||||
apiRequest.patch("/api/v2/users/me/name", {
|
||||
firstName: newName?.split(" ")[0],
|
||||
lastName: newName?.split(" ").slice(1).join(" ")
|
||||
}),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.getUser);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getUser });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -106,7 +109,7 @@ export const useUpdateUserAuthMethods = () => {
|
||||
return user;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.getUser);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getUser });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -152,18 +155,20 @@ export const useAddUsersToOrg = () => {
|
||||
};
|
||||
};
|
||||
|
||||
return useMutation<Response, {}, AddUserToOrgDTO>({
|
||||
return useMutation<Response, object, AddUserToOrgDTO>({
|
||||
mutationFn: (dto) => {
|
||||
return apiRequest.post("/api/v1/invite-org/signup", dto);
|
||||
},
|
||||
onSuccess: (_, { organizationId, projects }) => {
|
||||
queryClient.invalidateQueries(userKeys.getOrgUsers(organizationId));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgUsers(organizationId) });
|
||||
|
||||
projects?.forEach((project) => {
|
||||
if (project.slug) {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(project.slug));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(project.slug)
|
||||
});
|
||||
}
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(project.id));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(project.id) });
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -207,12 +212,12 @@ export const useGetOrgMembershipProjectMemberships = (
|
||||
export const useDeleteOrgMembership = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, DeletOrgMembershipDTO>({
|
||||
return useMutation<object, object, DeletOrgMembershipDTO>({
|
||||
mutationFn: ({ membershipId, orgId }) => {
|
||||
return apiRequest.delete(`/api/v2/organizations/${orgId}/memberships/${membershipId}`);
|
||||
},
|
||||
onSuccess: (_, { orgId }) => {
|
||||
queryClient.invalidateQueries(userKeys.getOrgUsers(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgUsers(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -220,15 +225,15 @@ export const useDeleteOrgMembership = () => {
|
||||
export const useDeactivateOrgMembership = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, DeletOrgMembershipDTO>({
|
||||
return useMutation<object, object, DeletOrgMembershipDTO>({
|
||||
mutationFn: ({ membershipId, orgId }) => {
|
||||
return apiRequest.post(
|
||||
`/api/v2/organizations/${orgId}/memberships/${membershipId}/deactivate`
|
||||
);
|
||||
},
|
||||
onSuccess: (_, { orgId, membershipId }) => {
|
||||
queryClient.invalidateQueries(userKeys.getOrgUsers(orgId));
|
||||
queryClient.invalidateQueries(userKeys.getOrgMembership(orgId, membershipId));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgUsers(orgId) });
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgMembership(orgId, membershipId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -236,7 +241,7 @@ export const useDeactivateOrgMembership = () => {
|
||||
export const useUpdateOrgMembership = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, UpdateOrgMembershipDTO>({
|
||||
return useMutation<object, object, UpdateOrgMembershipDTO>({
|
||||
mutationFn: ({ organizationId, membershipId, role, isActive, metadata }) => {
|
||||
return apiRequest.patch(
|
||||
`/api/v2/organizations/${organizationId}/memberships/${membershipId}`,
|
||||
@@ -248,23 +253,27 @@ export const useUpdateOrgMembership = () => {
|
||||
);
|
||||
},
|
||||
onSuccess: (_, { organizationId, membershipId }) => {
|
||||
queryClient.invalidateQueries(userKeys.getOrgUsers(organizationId));
|
||||
queryClient.invalidateQueries(userKeys.getOrgMembership(organizationId, membershipId));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgUsers(organizationId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: userKeys.getOrgMembership(organizationId, membershipId)
|
||||
});
|
||||
},
|
||||
// to remove old states
|
||||
onError: (_, { organizationId, membershipId }) => {
|
||||
queryClient.invalidateQueries(userKeys.getOrgUsers(organizationId));
|
||||
queryClient.invalidateQueries(userKeys.getOrgMembership(organizationId, membershipId));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getOrgUsers(organizationId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: userKeys.getOrgMembership(organizationId, membershipId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRegisterUserAction = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, string>({
|
||||
return useMutation<object, object, string>({
|
||||
mutationFn: (action) => apiRequest.post("/api/v1/user-action", { action }),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(userKeys.userAction);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.userAction });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -287,7 +296,6 @@ export const useLogoutUser = (keepQueryClient?: boolean) => {
|
||||
localStorage.removeItem("tag");
|
||||
localStorage.removeItem("PRIVATE_KEY");
|
||||
localStorage.removeItem("orgData.id");
|
||||
localStorage.removeItem("projectData.id");
|
||||
sessionStorage.removeItem(SessionStorageKeys.CLI_TERMINAL_TOKEN);
|
||||
|
||||
if (!keepQueryClient) {
|
||||
@@ -346,7 +354,7 @@ export const useCreateAPIKey = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(userKeys.myAPIKeys);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.myAPIKeys });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -361,7 +369,7 @@ export const useDeleteAPIKey = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(userKeys.myAPIKeys);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.myAPIKeys });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -387,7 +395,7 @@ export const useRevokeMySessions = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(userKeys.mySessions);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.mySessions });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -412,7 +420,7 @@ export const useUpdateUserMfa = () => {
|
||||
return user;
|
||||
},
|
||||
onSuccess() {
|
||||
queryClient.invalidateQueries(userKeys.getUser);
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.getUser });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,13 +8,13 @@ import { TCreateWebhookDto, TDeleteWebhookDto, TTestWebhookDTO, TUpdateWebhookDt
|
||||
export const useCreateWebhook = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateWebhookDto>({
|
||||
return useMutation<object, object, TCreateWebhookDto>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.post("/api/v1/webhooks", dto);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(queryKeys.getWebhooks(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -22,16 +22,16 @@ export const useCreateWebhook = () => {
|
||||
export const useTestWebhook = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TTestWebhookDTO>({
|
||||
return useMutation<object, object, TTestWebhookDTO>({
|
||||
mutationFn: async ({ webhookId }) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/webhooks/${webhookId}/test`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(queryKeys.getWebhooks(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
|
||||
},
|
||||
onError: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(queryKeys.getWebhooks(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -39,7 +39,7 @@ export const useTestWebhook = () => {
|
||||
export const useUpdateWebhook = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateWebhookDto>({
|
||||
return useMutation<object, object, TUpdateWebhookDto>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/webhooks/${dto.webhookId}`, {
|
||||
isDisabled: dto.isDisabled
|
||||
@@ -47,7 +47,7 @@ export const useUpdateWebhook = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(queryKeys.getWebhooks(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -55,13 +55,13 @@ export const useUpdateWebhook = () => {
|
||||
export const useDeleteWebhook = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteWebhookDto>({
|
||||
return useMutation<object, object, TDeleteWebhookDto>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/webhooks/${dto.webhookId}`);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(queryKeys.getWebhooks(workspaceId));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -13,15 +13,17 @@ import {
|
||||
export const useUpdateSlackIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSlackIntegrationDTO>({
|
||||
return useMutation<object, object, TUpdateSlackIntegrationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/workflow-integrations/slack/${dto.id}`, dto);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId, id }) => {
|
||||
queryClient.invalidateQueries(workflowIntegrationKeys.getSlackIntegration(id));
|
||||
queryClient.invalidateQueries(workflowIntegrationKeys.getSlackIntegrations(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getSlackIntegration(id) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workflowIntegrationKeys.getSlackIntegrations(orgId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -29,15 +31,15 @@ export const useUpdateSlackIntegration = () => {
|
||||
export const useDeleteSlackIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TDeleteSlackIntegrationDTO>({
|
||||
return useMutation<object, object, TDeleteSlackIntegrationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/workflow-integrations/slack/${dto.id}`);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { orgId, id }) => {
|
||||
queryClient.invalidateQueries(workflowIntegrationKeys.getSlackIntegration(id));
|
||||
queryClient.invalidateQueries(workflowIntegrationKeys.getIntegrations(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getSlackIntegration(id) });
|
||||
queryClient.invalidateQueries({ queryKey: workflowIntegrationKeys.getIntegrations(orgId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -54,7 +56,9 @@ export const useUpdateProjectSlackConfig = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceSlackConfig(workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceSlackConfig(workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { userKeys } from "../users/query-keys";
|
||||
import { workspaceKeys } from "./query-keys";
|
||||
import { ProjectType, TUpdateWorkspaceGroupRoleDTO } from "./types";
|
||||
import { TUpdateWorkspaceGroupRoleDTO } from "./types";
|
||||
|
||||
export const useAddGroupToWorkspace = () => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -27,7 +27,9 @@ export const useAddGroupToWorkspace = () => {
|
||||
return groupMembership;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -45,7 +47,9 @@ export const useUpdateGroupWorkspaceRole = () => {
|
||||
return groupMembership;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -67,10 +71,12 @@ export const useDeleteGroupFromWorkspace = () => {
|
||||
return groupMembership;
|
||||
},
|
||||
onSuccess: (_, { projectId, username }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceGroupMemberships(projectId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
|
||||
});
|
||||
|
||||
if (username) {
|
||||
queryClient.invalidateQueries(userKeys.listUserGroupMemberships(username));
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.listUserGroupMemberships(username) });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -78,24 +84,26 @@ export const useDeleteGroupFromWorkspace = () => {
|
||||
|
||||
export const useLeaveProject = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, { workspaceId: string }>({
|
||||
return useMutation<object, object, { workspaceId: string }>({
|
||||
mutationFn: ({ workspaceId }) => {
|
||||
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace());
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useMigrateProjectToV3 = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<{}, {}, { workspaceId: string }>({
|
||||
return useMutation<object, object, { workspaceId: string }>({
|
||||
mutationFn: ({ workspaceId }) => {
|
||||
return apiRequest.post(`/api/v1/workspace/${workspaceId}/migrate-v3`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(ProjectType.SecretManager));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ import { TIntegration } from "../integrations/types";
|
||||
import { TPkiAlert } from "../pkiAlerts/types";
|
||||
import { TPkiCollection } from "../pkiCollections/types";
|
||||
import { EncryptedSecret } from "../secrets/types";
|
||||
import { TSshCertificate, TSshCertificateAuthority } from "../ssh-ca/types";
|
||||
import { TSshCertificate, TSshCertificateAuthority } from "../sshCa/types";
|
||||
import { TSshCertificateTemplate } from "../sshCertificateTemplates/types";
|
||||
import { userKeys } from "../users/query-keys";
|
||||
import { TWorkspaceUser } from "../users/types";
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
Workspace
|
||||
} from "./types";
|
||||
|
||||
const fetchWorkspaceById = async (workspaceId: string) => {
|
||||
export const fetchWorkspaceById = async (workspaceId: string) => {
|
||||
const { data } = await apiRequest.get<{ workspace: Workspace }>(
|
||||
`/api/v1/workspace/${workspaceId}`
|
||||
);
|
||||
@@ -78,21 +78,22 @@ export const fetchWorkspaceSecrets = async (workspaceId: string) => {
|
||||
export const useUpgradeProject = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, { projectId: string; privateKey: string }>({
|
||||
return useMutation<object, object, { projectId: string; privateKey: string }>({
|
||||
mutationFn: ({ projectId, privateKey }) => {
|
||||
return apiRequest.post(`/api/v2/workspace/${projectId}/upgrade`, {
|
||||
userPrivateKey: privateKey
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(ProjectType.SecretManager));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetUpgradeProjectStatus = ({
|
||||
projectId,
|
||||
onSuccess,
|
||||
enabled,
|
||||
refetchInterval
|
||||
}: TGetUpgradeProjectStatusDTO) => {
|
||||
@@ -100,7 +101,6 @@ export const useGetUpgradeProjectStatus = ({
|
||||
queryKey: workspaceKeys.getProjectUpgradeStatus(projectId),
|
||||
queryFn: () => fetchProjectUpgradeStatus(projectId),
|
||||
enabled,
|
||||
onSuccess,
|
||||
refetchInterval
|
||||
});
|
||||
};
|
||||
@@ -150,9 +150,10 @@ export const useGetUserWorkspaces = ({
|
||||
includeRoles?: boolean;
|
||||
type?: ProjectType | "all";
|
||||
} = {}) =>
|
||||
useQuery(workspaceKeys.getAllUserWorkspace(type || ""), () =>
|
||||
fetchUserWorkspaces(includeRoles, type)
|
||||
);
|
||||
useQuery({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace(type),
|
||||
queryFn: () => fetchUserWorkspaces(includeRoles, type)
|
||||
});
|
||||
|
||||
const fetchUserWorkspaceMemberships = async (orgId: string) => {
|
||||
const { data } = await apiRequest.get<Record<string, Workspace[]>>(
|
||||
@@ -173,13 +174,15 @@ export const useGetUserWorkspaceMemberships = (orgId: string) =>
|
||||
export const useNameWorkspaceSecrets = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, NameWorkspaceSecretsDTO>({
|
||||
return useMutation<object, object, NameWorkspaceSecretsDTO>({
|
||||
mutationFn: async ({ workspaceId, secretsToUpdate }) =>
|
||||
apiRequest.post(`/api/v3/workspaces/${workspaceId}/secrets/names`, {
|
||||
secretsToUpdate
|
||||
}),
|
||||
onSuccess: (_, variables) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIndexStatus(variables.workspaceId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIndexStatus(variables.workspaceId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -227,7 +230,7 @@ export const createWorkspace = (
|
||||
export const useCreateWorkspace = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ data: { project: Workspace } }, {}, CreateWorkspaceDTO>({
|
||||
return useMutation<{ data: { project: Workspace } }, object, CreateWorkspaceDTO>({
|
||||
mutationFn: async ({ projectName, projectDescription, kmsKeyId, template, type }) =>
|
||||
createWorkspace({
|
||||
projectName,
|
||||
@@ -237,7 +240,9 @@ export const useCreateWorkspace = () => {
|
||||
type
|
||||
}),
|
||||
onSuccess: (dto) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(dto.data.project.type));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace(dto.data.project.type)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -245,7 +250,7 @@ export const useCreateWorkspace = () => {
|
||||
export const useUpdateProject = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<Workspace, {}, UpdateProjectDTO>({
|
||||
return useMutation<Workspace, object, UpdateProjectDTO>({
|
||||
mutationFn: async ({ projectID, newProjectName, newProjectDescription }) => {
|
||||
const { data } = await apiRequest.patch<{ workspace: Workspace }>(
|
||||
`/api/v1/workspace/${projectID}`,
|
||||
@@ -256,8 +261,8 @@ export const useUpdateProject = () => {
|
||||
);
|
||||
return data.workspace;
|
||||
},
|
||||
onSuccess: (dto) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(dto.type));
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -265,7 +270,7 @@ export const useUpdateProject = () => {
|
||||
export const useToggleAutoCapitalization = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<Workspace, {}, ToggleAutoCapitalizationDTO>({
|
||||
return useMutation<Workspace, object, ToggleAutoCapitalizationDTO>({
|
||||
mutationFn: async ({ workspaceID, state }) => {
|
||||
const { data } = await apiRequest.post<{ workspace: Workspace }>(
|
||||
`/api/v1/workspace/${workspaceID}/auto-capitalization`,
|
||||
@@ -275,8 +280,8 @@ export const useToggleAutoCapitalization = () => {
|
||||
);
|
||||
return data.workspace;
|
||||
},
|
||||
onSuccess: (dto) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(dto.type));
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -284,15 +289,15 @@ export const useToggleAutoCapitalization = () => {
|
||||
export const useUpdateWorkspaceVersionLimit = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<Workspace, {}, UpdatePitVersionLimitDTO>({
|
||||
return useMutation<Workspace, object, UpdatePitVersionLimitDTO>({
|
||||
mutationFn: async ({ projectSlug, pitVersionLimit }) => {
|
||||
const { data } = await apiRequest.put(`/api/v1/workspace/${projectSlug}/version-limit`, {
|
||||
pitVersionLimit
|
||||
});
|
||||
return data.workspace;
|
||||
},
|
||||
onSuccess: (dto) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(dto.type));
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -300,7 +305,7 @@ export const useUpdateWorkspaceVersionLimit = () => {
|
||||
export const useUpdateWorkspaceAuditLogsRetention = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<Workspace, {}, UpdateAuditLogsRetentionDTO>({
|
||||
return useMutation<Workspace, object, UpdateAuditLogsRetentionDTO>({
|
||||
mutationFn: async ({ projectSlug, auditLogsRetentionDays }) => {
|
||||
const { data } = await apiRequest.put(
|
||||
`/api/v1/workspace/${projectSlug}/audit-logs-retention`,
|
||||
@@ -311,7 +316,7 @@ export const useUpdateWorkspaceAuditLogsRetention = () => {
|
||||
return data.workspace;
|
||||
},
|
||||
onSuccess: (dto) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(dto.type));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace(dto.type) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -319,14 +324,16 @@ export const useUpdateWorkspaceAuditLogsRetention = () => {
|
||||
export const useDeleteWorkspace = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<Workspace, {}, DeleteWorkspaceDTO>({
|
||||
return useMutation<Workspace, object, DeleteWorkspaceDTO>({
|
||||
mutationFn: async ({ workspaceID }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v1/workspace/${workspaceID}`);
|
||||
return data.workspace;
|
||||
},
|
||||
onSuccess: (dto) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(dto.type));
|
||||
queryClient.invalidateQueries(["org-admin-projects"]);
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace(dto.type) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["org-admin-projects"]
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -334,7 +341,7 @@ export const useDeleteWorkspace = () => {
|
||||
export const useCreateWsEnvironment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, CreateEnvironmentDTO>({
|
||||
return useMutation<object, object, CreateEnvironmentDTO>({
|
||||
mutationFn: ({ workspaceId, name, slug }) => {
|
||||
return apiRequest.post(`/api/v1/workspace/${workspaceId}/environments`, {
|
||||
name,
|
||||
@@ -342,7 +349,9 @@ export const useCreateWsEnvironment = () => {
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(ProjectType.SecretManager));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -350,7 +359,7 @@ export const useCreateWsEnvironment = () => {
|
||||
export const useUpdateWsEnvironment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, UpdateEnvironmentDTO>({
|
||||
return useMutation<object, object, UpdateEnvironmentDTO>({
|
||||
mutationFn: ({ workspaceId, id, name, slug, position }) => {
|
||||
return apiRequest.patch(`/api/v1/workspace/${workspaceId}/environments/${id}`, {
|
||||
name,
|
||||
@@ -359,7 +368,9 @@ export const useUpdateWsEnvironment = () => {
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(ProjectType.SecretManager));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -367,12 +378,14 @@ export const useUpdateWsEnvironment = () => {
|
||||
export const useDeleteWsEnvironment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, DeleteEnvironmentDTO>({
|
||||
return useMutation<object, object, DeleteEnvironmentDTO>({
|
||||
mutationFn: ({ id, workspaceId }) => {
|
||||
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/environments/${id}`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace(ProjectType.SecretManager));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getAllUserWorkspace()
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -432,8 +445,10 @@ export const useDeleteUserFromWorkspace = () => {
|
||||
return deletedMembership;
|
||||
},
|
||||
onSuccess: (_, { orgId, workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(workspaceId));
|
||||
queryClient.invalidateQueries(userKeys.allOrgMembershipProjectMemberships(orgId));
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -453,10 +468,10 @@ export const useUpdateUserWorkspaceRole = () => {
|
||||
return membership;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, membershipId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(workspaceId));
|
||||
queryClient.invalidateQueries(
|
||||
workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId)
|
||||
);
|
||||
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -485,8 +500,12 @@ export const useAddIdentityToWorkspace = () => {
|
||||
return identityMembership;
|
||||
},
|
||||
onSuccess: (_, { identityId, workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIdentityMemberships(workspaceId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityProjectMemberships(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -507,11 +526,15 @@ export const useUpdateIdentityWorkspaceRole = () => {
|
||||
return identityMembership;
|
||||
},
|
||||
onSuccess: (_, { identityId, workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIdentityMemberships(workspaceId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityProjectMemberships(identityId));
|
||||
queryClient.invalidateQueries(
|
||||
workspaceKeys.getWorkspaceIdentityMembershipDetails(workspaceId, identityId)
|
||||
);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIdentityMembershipDetails(workspaceId, identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -534,8 +557,12 @@ export const useDeleteIdentityFromWorkspace = () => {
|
||||
return identityMembership;
|
||||
},
|
||||
onSuccess: (_, { identityId, workspaceId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceIdentityMemberships(workspaceId));
|
||||
queryClient.invalidateQueries(identitiesKeys.getIdentityProjectMemberships(identityId));
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { TListProjectIdentitiesDTO } from "@app/hooks/api/workspace/types";
|
||||
import type { CaStatus } from "../ca";
|
||||
|
||||
export const workspaceKeys = {
|
||||
getWorkspaceById: (workspaceId: string) => [{ workspaceId }, "workspace"] as const,
|
||||
getWorkspaceById: (workspaceId: string) => ["workspaces", { workspaceId }] as const,
|
||||
getWorkspaceSecrets: (workspaceId: string) => [{ workspaceId }, "workspace-secrets"] as const,
|
||||
getWorkspaceIndexStatus: (workspaceId: string) =>
|
||||
[{ workspaceId }, "workspace-index-status"] as const,
|
||||
@@ -12,7 +12,7 @@ export const workspaceKeys = {
|
||||
getWorkspaceAuthorization: (workspaceId: string) => [{ workspaceId }, "workspace-authorizations"],
|
||||
getWorkspaceIntegrations: (workspaceId: string) => [{ workspaceId }, "workspace-integrations"],
|
||||
getAllUserWorkspace: (type?: string) =>
|
||||
type ? ["workspaces", { type }] : (["workspace"] as const),
|
||||
type ? ["workspaces", { type }] : (["workspaces"] as const),
|
||||
getWorkspaceAuditLogs: (workspaceId: string) =>
|
||||
[{ workspaceId }, "workspace-audit-logs"] as const,
|
||||
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }, "workspace-users"] as const,
|
||||
|
||||
Reference in New Issue
Block a user