featL completed v1 routes for projects

This commit is contained in:
=
2025-09-16 00:08:40 +05:30
parent 2509890bab
commit cd2a39b374
40 changed files with 2147 additions and 743 deletions
@@ -1,7 +1,7 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { useParams } from "@tanstack/react-router";
import { workspaceKeys } from "@app/hooks/api";
import { projectKeys } from "@app/hooks/api";
import { fetchWorkspaceById } from "@app/hooks/api/workspace/queries";
export const useWorkspace = () => {
@@ -13,7 +13,7 @@ export const useWorkspace = () => {
}
const { data: currentWorkspace } = useSuspenseQuery({
queryKey: workspaceKeys.getWorkspaceById(params.projectId),
queryKey: projectKeys.getWorkspaceById(params.projectId),
queryFn: () => fetchWorkspaceById(params.projectId as string),
staleTime: Infinity
});
@@ -7,27 +7,27 @@ import { Commit, CommitHistoryItem, CommitWithChanges, RollbackPreview } from ".
export const commitKeys = {
count: ({
workspaceId,
projectId,
environment,
directory
}: {
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
}) => [{ workspaceId, environment, directory }, "folder-commits-count"] as const,
}) => [{ projectId, environment, directory }, "folder-commits-count"] as const,
history: ({
workspaceId,
projectId,
environment,
directory
}: {
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
}) => [{ workspaceId, environment, directory }, "folder-commits"] as const,
}) => [{ projectId, environment, directory }, "folder-commits"] as const,
details: ({ workspaceId, commitId }: { workspaceId: string; commitId: string }) =>
[{ workspaceId, commitId }, "commit-details"] as const,
details: ({ projectId, commitId }: { projectId: string; commitId: string }) =>
[{ projectId, commitId }, "commit-details"] as const,
rollbackPreview: ({
folderId,
@@ -45,11 +45,11 @@ export const commitKeys = {
};
const fetchFolderCommitsCount = async ({
workspaceId,
projectId,
environment,
directory
}: {
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
}) => {
@@ -59,7 +59,7 @@ const fetchFolderCommitsCount = async ({
params: {
environment,
path: directory,
projectId: workspaceId
projectId
}
}
);
@@ -67,7 +67,7 @@ const fetchFolderCommitsCount = async ({
};
const fetchFolderCommitHistory = async (
workspaceId: string,
projectId: string,
environment: string,
directory: string,
offset: number = 0,
@@ -87,7 +87,7 @@ const fetchFolderCommitHistory = async (
params: {
environment,
path: directory,
projectId: workspaceId,
projectId: projectId,
offset,
limit,
search,
@@ -97,12 +97,12 @@ const fetchFolderCommitHistory = async (
return res.data;
};
export const fetchCommitDetails = async (workspaceId: string, commitId: string) => {
export const fetchCommitDetails = async (projectId: string, commitId: string) => {
const { data } = await apiRequest.get<CommitWithChanges>(
`/api/v1/pit/commits/${commitId}/changes`,
{
params: {
projectId: workspaceId
projectId: projectId
}
}
);
@@ -113,7 +113,7 @@ export const fetchRollbackPreview = async (
folderId: string,
commitId: string,
envSlug: string,
workspaceId: string,
projectId: string,
deepRollback: boolean,
secretPath: string
): Promise<RollbackPreview[]> => {
@@ -125,7 +125,7 @@ export const fetchRollbackPreview = async (
environment: envSlug,
deepRollback,
secretPath,
projectId: workspaceId
projectId: projectId
}
}
);
@@ -135,7 +135,7 @@ export const fetchRollbackPreview = async (
const fetchRollback = async (
folderId: string,
commitId: string,
workspaceId: string,
projectId: string,
deepRollback: boolean,
message?: string,
envSlug?: string
@@ -147,17 +147,17 @@ const fetchRollback = async (
deepRollback,
message,
environment: envSlug,
projectId: workspaceId
projectId
}
);
return data;
};
const fetchRevert = async (commitId: string, workspaceId: string) => {
const fetchRevert = async (commitId: string, projectId: string) => {
const { data } = await apiRequest.post<{ success: boolean; message: string }>(
`/api/v1/pit/commits/${commitId}/revert`,
{
projectId: workspaceId
projectId: projectId
}
);
return data;
@@ -180,9 +180,9 @@ export const useCommitRevert = ({
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [
commitKeys.details({ workspaceId: projectId, commitId }),
commitKeys.history({ workspaceId: projectId, environment, directory }),
commitKeys.count({ workspaceId: projectId, environment, directory })
commitKeys.details({ projectId, commitId }),
commitKeys.history({ projectId, environment, directory }),
commitKeys.count({ projectId, environment, directory })
]
});
}
@@ -190,7 +190,7 @@ export const useCommitRevert = ({
};
export const useCommitRollback = ({
workspaceId,
projectId,
commitId,
folderId,
deepRollback,
@@ -198,7 +198,7 @@ export const useCommitRollback = ({
directory,
envSlug
}: {
workspaceId: string;
projectId: string;
commitId: string;
folderId: string;
deepRollback: boolean;
@@ -209,13 +209,13 @@ export const useCommitRollback = ({
const queryClient = useQueryClient();
return useMutation({
mutationFn: (message: string) =>
fetchRollback(folderId, commitId, workspaceId, deepRollback, message, envSlug),
fetchRollback(folderId, commitId, projectId, deepRollback, message, envSlug),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [
commitKeys.details({ workspaceId, commitId }),
commitKeys.history({ workspaceId, environment, directory }),
commitKeys.count({ workspaceId, environment, directory })
commitKeys.details({ projectId, commitId }),
commitKeys.history({ projectId, environment, directory }),
commitKeys.count({ projectId, environment, directory })
]
});
}
@@ -223,31 +223,31 @@ export const useCommitRollback = ({
};
export const useGetFolderCommitsCount = ({
workspaceId,
projectId,
environment,
directory,
isPaused
}: {
workspaceId: string;
projectId: string;
environment: string;
directory: string;
isPaused?: boolean;
}) =>
useQuery({
enabled: Boolean(workspaceId && environment) && !isPaused,
queryKey: commitKeys.count({ workspaceId, environment, directory }),
queryFn: () => fetchFolderCommitsCount({ workspaceId, environment, directory })
enabled: Boolean(projectId && environment) && !isPaused,
queryKey: commitKeys.count({ projectId: projectId, environment, directory }),
queryFn: () => fetchFolderCommitsCount({ projectId, environment, directory })
});
export const useGetFolderCommitHistory = ({
workspaceId,
projectId,
environment,
directory,
limit = 20,
search,
sort = "desc"
}: {
workspaceId: string;
projectId: string;
environment: string;
directory: string;
limit?: number;
@@ -256,10 +256,10 @@ export const useGetFolderCommitHistory = ({
}) => {
return useInfiniteQuery({
initialPageParam: 0,
queryKey: [commitKeys.history({ workspaceId, environment, directory }), limit, search, sort],
queryKey: [commitKeys.history({ projectId, environment, directory }), limit, search, sort],
queryFn: ({ pageParam }) =>
fetchFolderCommitHistory(workspaceId, environment, directory, pageParam, limit, search, sort),
enabled: Boolean(workspaceId && environment),
fetchFolderCommitHistory(projectId, environment, directory, pageParam, limit, search, sort),
enabled: Boolean(projectId && environment),
select: (data) => {
return (data?.pages ?? [])
?.map((page) => page.commits)
@@ -280,11 +280,11 @@ export const useGetFolderCommitHistory = ({
});
};
export const useGetCommitDetails = (workspaceId: string, commitId: string) => {
export const useGetCommitDetails = (projectId: string, commitId: string) => {
return useQuery({
queryKey: commitKeys.details({ workspaceId, commitId }),
queryFn: () => fetchCommitDetails(workspaceId, commitId),
enabled: Boolean(workspaceId) && Boolean(commitId)
queryKey: commitKeys.details({ projectId, commitId }),
queryFn: () => fetchCommitDetails(projectId, commitId),
enabled: Boolean(projectId) && Boolean(commitId)
});
};
+2 -2
View File
@@ -1,7 +1,7 @@
import { OrderByDirection } from "../generic/types";
import { OrgIdentityOrderBy } from "../organization/types";
import { TOrgRole } from "../roles/types";
import { ProjectUserMembershipTemporaryMode, Workspace } from "../workspace/types";
import { ProjectUserMembershipTemporaryMode, Project } from "../workspace/types";
import { IdentityAuthMethod, IdentityJwtConfigurationType } from "./enums";
export type IdentityTrustedIp = {
@@ -54,7 +54,7 @@ export type IdentityMembershipOrg = {
export type IdentityMembership = {
id: string;
identity: Identity;
project: Pick<Workspace, "id" | "name" | "type">;
project: Pick<Project, "id" | "name" | "type">;
roles: Array<
{
id: string;
-1
View File
@@ -1 +0,0 @@
export { useGetUserWsKey, useUploadWsKey } from "./queries";
-43
View File
@@ -1,43 +0,0 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { UploadWsKeyDTO, UserWsKeyPair } from "./types";
const encKeyKeys = {
getUserWorkspaceKey: (workspaceID: string) => ["workspace-key-pair", { workspaceID }] as const
};
export const fetchUserWsKey = async (projectId: string) => {
const { data } = await apiRequest.get<UserWsKeyPair>(
`/api/v2/workspace/${projectId}/encrypted-key`
);
return data;
};
export const useGetUserWsKey = (workspaceID: string) =>
useQuery({
queryKey: encKeyKeys.getUserWorkspaceKey(workspaceID),
queryFn: () => fetchUserWsKey(workspaceID),
enabled: Boolean(workspaceID)
});
// mutations
export const uploadWsKey = async ({ workspaceId, userId, encryptedKey, nonce }: UploadWsKeyDTO) => {
return apiRequest.post(`/api/v1/workspace/${workspaceId}/key`, {
key: { userId, encryptedKey, nonce }
});
};
export const useUploadWsKey = () =>
useMutation<object, object, UploadWsKeyDTO>({
mutationFn: async ({ encryptedKey, nonce, userId, workspaceId }) => {
return uploadWsKey({
workspaceId,
userId,
encryptedKey,
nonce
});
}
});
-29
View File
@@ -1,29 +0,0 @@
export type UserWsKeyPair = {
id: string;
encryptedKey: string;
nonce: string;
sender: Sender;
receiver: string;
workspace: string;
createdAt: string;
updatedAt: string;
__v: number;
};
export type Sender = {
id: string;
email: string;
createdAt: string;
updatedAt: string;
__v: number;
firstName: string;
lastName: string;
publicKey: string;
};
export type UploadWsKeyDTO = {
userId: string;
encryptedKey: string;
nonce: string;
workspaceId: string;
};
@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TCreateCertificateResponse } from "../ca/types";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../workspace/query-keys";
import { pkiSubscriberKeys } from "./queries";
import {
TCreatePkiSubscriberDTO,
@@ -22,7 +22,7 @@ export const useCreatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -46,7 +46,7 @@ export const useUpdatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -74,7 +74,7 @@ export const useDeletePkiSubscriber = () => {
},
onSuccess: ({ name, projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -57,7 +57,7 @@ export const useListProjectEnvironmentsFolders = (
queryKey: folderQueryKeys.getProjectEnvironmentsFolders(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<TProjectEnvironmentsFolders>(
`/api/v1/workspace/${projectId}/environment-folder-tree`
`/api/v1/projects/${projectId}/environment-folder-tree`
);
return data;
},
@@ -162,13 +162,13 @@ export const useCreateFolder = () => {
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.count({ projectId, environment, directory: path })
});
}
});
@@ -199,16 +199,16 @@ export const useUpdateFolder = () => {
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.history({ projectId, environment, directory: path })
});
}
});
@@ -239,16 +239,16 @@ export const useDeleteFolder = () => {
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.history({ projectId, environment, directory: path })
});
}
});
@@ -283,28 +283,28 @@ export const useUpdateFolderBatch = () => {
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
+8 -8
View File
@@ -66,7 +66,7 @@ export const useCreateSecretV3 = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -131,7 +131,7 @@ export const useUpdateSecretV3 = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -183,7 +183,7 @@ export const useDeleteSecretV3 = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -225,7 +225,7 @@ export const useCreateSecretBatch = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -267,7 +267,7 @@ export const useUpdateSecretBatch = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -311,7 +311,7 @@ export const useDeleteSecretBatch = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -391,7 +391,7 @@ export const useMoveSecrets = ({
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({
workspaceId: projectId,
projectId: projectId,
environment: sourceEnvironment,
directory: sourceSecretPath
})
@@ -515,7 +515,7 @@ export const useCreateCommit = () => {
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -13,9 +13,9 @@ const serviceTokenKeys = {
getAllWorkspaceServiceToken: (workspaceID: string) => [{ workspaceID }, "service-tokens"] as const
};
const fetchWorkspaceServiceTokens = async (workspaceID: string) => {
const fetchWorkspaceServiceTokens = async (projectID: string) => {
const { data } = await apiRequest.get<{ serviceTokenData: ServiceToken[] }>(
`/api/v1/workspace/${workspaceID}/service-token-data`
`/api/v1/projects/${projectID}/service-token-data`
);
return data.serviceTokenData;
+6 -6
View File
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../workspace/query-keys";
import {
TCreateSshCaDTO,
TDeleteSshCaDTO,
@@ -28,7 +28,7 @@ export const useCreateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(projectId) });
}
});
};
@@ -43,7 +43,7 @@ export const useUpdateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }, { caId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaById(caId) });
}
});
@@ -59,7 +59,7 @@ export const useDeleteSshCa = () => {
return ca;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(projectId) });
}
});
};
@@ -76,7 +76,7 @@ export const useSignSshKey = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
queryKey: projectKeys.allWorkspaceSshCertificates(projectId)
});
}
});
@@ -94,7 +94,7 @@ export const useIssueSshCreds = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
queryKey: projectKeys.allWorkspaceSshCertificates(projectId)
});
}
});
+4 -4
View File
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../workspace/query-keys";
import { TCreateSshHostDTO, TDeleteSshHostDTO, TSshHost, TUpdateSshHostDTO } from "./types";
export const useCreateSshHost = () => {
@@ -13,7 +13,7 @@ export const useCreateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
}
});
};
@@ -26,7 +26,7 @@ export const useUpdateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
}
});
};
@@ -39,7 +39,7 @@ export const useDeleteSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
}
});
};
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../workspace/query-keys";
import { sshHostGroupKeys } from "./queries";
import {
TCreateSshHostGroupDTO,
@@ -20,7 +20,7 @@ export const useCreateSshHostGroup = () => {
},
onSuccess: ({ projectId, id }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(id)
@@ -41,10 +41,10 @@ export const useUpdateSshHostGroup = () => {
},
onSuccess: ({ projectId }, { sshHostGroupId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHosts(projectId)
queryKey: projectKeys.getWorkspaceSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)
@@ -64,10 +64,10 @@ export const useDeleteSshHostGroup = () => {
},
onSuccess: ({ projectId }, { sshHostGroupId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHosts(projectId)
queryKey: projectKeys.getWorkspaceSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)
+1 -2
View File
@@ -7,7 +7,6 @@ export type { GetAuthTokenAPI } from "./auth/types";
export type { IncidentContact } from "./incidentContacts/types";
export type { IntegrationAuth } from "./integrationAuth/types";
export type { TCloudIntegration, TIntegration } from "./integrations/types";
export type { UserWsKeyPair } from "./keys/types";
export type { Organization } from "./organization/types";
export type { TSecretApprovalPolicy } from "./secretApproval/types";
export type {
@@ -37,7 +36,7 @@ export type {
ToggleAutoCapitalizationDTO,
UpdateEnvironmentDTO,
UpdateProjectDTO,
Workspace,
Project as Workspace,
WorkspaceEnv,
WorkspaceTag
} from "./workspace/types";
+3 -3
View File
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../workspace";
import { userKeys } from "./query-keys";
import { AddUserToWsDTONonE2EE } from "./types";
@@ -11,14 +11,14 @@ export const useAddUserToWsNonE2EE = () => {
return useMutation<object, object, AddUserToWsDTONonE2EE>({
mutationFn: async ({ projectId, usernames, roleSlugs }) => {
const { data } = await apiRequest.post(`/api/v2/workspace/${projectId}/memberships`, {
const { data } = await apiRequest.post(`/api/v1/projects/${projectId}/memberships`, {
usernames,
roleSlugs
});
return data;
},
onSuccess: (_, { orgId, projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../workspace/query-keys";
import { workflowIntegrationKeys } from "./queries";
import {
TCheckMicrosoftTeamsIntegrationInstallationStatusDTO,
@@ -126,7 +126,7 @@ export const useUpdateProjectWorkflowIntegrationConfig = () => {
},
onSuccess: (_, { workspaceId, integration }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
});
}
});
@@ -145,7 +145,7 @@ export const useDeleteProjectWorkflowIntegration = () => {
},
onSuccess: (_, { projectId, integration }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
});
}
});
+1 -1
View File
@@ -50,4 +50,4 @@ export {
useUpdateWsEnvironment,
useUpgradeProject
} from "./queries";
export { workspaceKeys } from "./query-keys";
export { projectKeys } from "./query-keys";
@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { userKeys } from "../users/query-keys";
import { workspaceKeys as projectKeys } from "./query-keys";
import { projectKeys } from "./query-keys";
import {
TProjectSshConfig,
TUpdateProjectSshConfigDTO,
@@ -24,7 +24,7 @@ export const useAddGroupToWorkspace = () => {
}) => {
const {
data: { groupMembership }
} = await apiRequest.post(`/api/v2/workspace/${projectId}/groups/${groupId}`, {
} = await apiRequest.post(`/api/v1/projects/${projectId}/groups/${groupId}`, {
role
});
@@ -44,7 +44,7 @@ export const useUpdateGroupWorkspaceRole = () => {
mutationFn: async ({ groupId, projectId, roles }: TUpdateWorkspaceGroupRoleDTO) => {
const {
data: { groupMembership }
} = await apiRequest.patch(`/api/v2/workspace/${projectId}/groups/${groupId}`, {
} = await apiRequest.patch(`/api/v1/projects/${projectId}/groups/${groupId}`, {
roles
});
@@ -74,7 +74,7 @@ export const useDeleteGroupFromWorkspace = () => {
}) => {
const {
data: { groupMembership }
} = await apiRequest.delete(`/api/v2/workspace/${projectId}/groups/${groupId}`);
} = await apiRequest.delete(`/api/v1/projects/${projectId}/groups/${groupId}`);
return groupMembership;
},
onSuccess: (_, { projectId, username }) => {
@@ -91,9 +91,9 @@ export const useDeleteGroupFromWorkspace = () => {
export const useLeaveProject = () => {
const queryClient = useQueryClient();
return useMutation<object, object, { workspaceId: string }>({
mutationFn: ({ workspaceId }) => {
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
return useMutation<object, object, { projectId: string }>({
mutationFn: ({ projectId }) => {
return apiRequest.delete(`/api/v1/projects/${projectId}/leave`);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
@@ -118,7 +118,7 @@ export const useMigrateProjectToV3 = () => {
export const useRequestProjectAccess = () => {
return useMutation<object, object, { projectId: string; comment: string }>({
mutationFn: ({ projectId, comment }) => {
return apiRequest.post(`/api/v1/workspace/${projectId}/project-access`, {
return apiRequest.post(`/api/v1/projects/${projectId}/project-access`, {
comment
});
}
@@ -129,7 +129,7 @@ export const useUpdateProjectSshConfig = () => {
const queryClient = useQueryClient();
return useMutation<TProjectSshConfig, object, TUpdateProjectSshConfigDTO>({
mutationFn: ({ projectId, defaultUserSshCaId, defaultHostSshCaId }) => {
return apiRequest.patch(`/api/v1/workspace/${projectId}/ssh-config`, {
return apiRequest.patch(`/api/v1/projects/${projectId}/ssh-config`, {
defaultUserSshCaId,
defaultHostSshCaId
});
+175 -190
View File
@@ -26,7 +26,7 @@ import {
ProjectWorkflowIntegrationConfig,
WorkflowIntegrationPlatform
} from "../workflowIntegrations/types";
import { workspaceKeys } from "./query-keys";
import { projectKeys } from "./query-keys";
import {
CreateEnvironmentDTO,
CreateWorkspaceDTO,
@@ -47,21 +47,19 @@ import {
UpdateEnvironmentDTO,
UpdatePitVersionLimitDTO,
UpdateProjectDTO,
Workspace,
Project,
WorkspaceEnv
} from "./types";
export const fetchWorkspaceById = async (workspaceId: string) => {
const { data } = await apiRequest.get<{ workspace: Workspace }>(
`/api/v1/workspace/${workspaceId}`
);
export const fetchWorkspaceById = async (projectId: string) => {
const { data } = await apiRequest.get<{ project: Project }>(`/api/v1/projects/${projectId}`);
return data.workspace;
return data.project;
};
const fetchWorkspaceIndexStatus = async (workspaceId: string) => {
const fetchWorkspaceIndexStatus = async (projectId: string) => {
const { data } = await apiRequest.get<boolean>(
`/api/v3/workspaces/${workspaceId}/secrets/blind-index-status`
`/api/v3/projects/${projectId}/secrets/blind-index-status`
);
return data;
@@ -69,18 +67,16 @@ const fetchWorkspaceIndexStatus = async (workspaceId: string) => {
const fetchProjectUpgradeStatus = async (projectId: string) => {
const { data } = await apiRequest.get<{ status: string }>(
`/api/v2/workspace/${projectId}/upgrade/status`
`/api/v1/projects/${projectId}/upgrade/status`
);
return data;
};
export const fetchWorkspaceSecrets = async (workspaceId: string) => {
export const fetchWorkspaceSecrets = async (projectId: string) => {
const {
data: { secrets }
} = await apiRequest.get<{ secrets: EncryptedSecret[] }>(
`/api/v3/workspaces/${workspaceId}/secrets`
);
} = await apiRequest.get<{ secrets: EncryptedSecret[] }>(`/api/v3/projects/${projectId}/secrets`);
return secrets;
};
@@ -90,13 +86,13 @@ export const useUpgradeProject = () => {
return useMutation<object, object, { projectId: string; privateKey: string }>({
mutationFn: ({ projectId, privateKey }) => {
return apiRequest.post(`/api/v2/workspace/${projectId}/upgrade`, {
return apiRequest.post(`/api/v1/projects/${projectId}/upgrade`, {
userPrivateKey: privateKey
});
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -108,7 +104,7 @@ export const useGetUpgradeProjectStatus = ({
refetchInterval
}: TGetUpgradeProjectStatusDTO) => {
return useQuery({
queryKey: workspaceKeys.getProjectUpgradeStatus(projectId),
queryKey: projectKeys.getProjectUpgradeStatus(projectId),
queryFn: () => fetchProjectUpgradeStatus(projectId),
enabled,
refetchInterval
@@ -116,39 +112,39 @@ export const useGetUpgradeProjectStatus = ({
};
const fetchUserWorkspaces = async (includeRoles?: boolean, type?: ProjectType | "all") => {
const { data } = await apiRequest.get<{ workspaces: Workspace[] }>("/api/v1/workspace", {
const { data } = await apiRequest.get<{ projects: Project[] }>("/api/v1/projects", {
params: {
includeRoles,
type
}
});
return data.workspaces;
return data.projects;
};
export const useGetWorkspaceIndexStatus = (workspaceId: string) => {
export const useGetWorkspaceIndexStatus = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceIndexStatus(workspaceId),
queryFn: () => fetchWorkspaceIndexStatus(workspaceId),
queryKey: projectKeys.getWorkspaceIndexStatus(projectId),
queryFn: () => fetchWorkspaceIndexStatus(projectId),
enabled: true
});
};
export const useGetWorkspaceSecrets = (workspaceId: string) => {
export const useGetWorkspaceSecrets = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceSecrets(workspaceId),
queryFn: () => fetchWorkspaceSecrets(workspaceId),
queryKey: projectKeys.getWorkspaceSecrets(projectId),
queryFn: () => fetchWorkspaceSecrets(projectId),
enabled: true
});
};
export const useGetWorkspaceById = (
workspaceId: string,
projectId: string,
dto?: { refetchInterval?: number | false }
) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceById(workspaceId),
queryFn: () => fetchWorkspaceById(workspaceId),
enabled: Boolean(workspaceId),
queryKey: projectKeys.getWorkspaceById(projectId),
queryFn: () => fetchWorkspaceById(projectId),
enabled: Boolean(projectId),
refetchInterval: dto?.refetchInterval
});
};
@@ -161,19 +157,19 @@ export const useGetUserWorkspaces = ({
options?: { enabled?: boolean };
} = {}) =>
useQuery({
queryKey: workspaceKeys.getAllUserWorkspace(),
queryKey: projectKeys.getAllUserWorkspace(),
queryFn: () => fetchUserWorkspaces(includeRoles),
...options
});
export const useSearchProjects = ({ options, ...dto }: TSearchProjectsDTO) =>
useQuery({
queryKey: workspaceKeys.searchWorkspace(dto),
queryKey: projectKeys.searchWorkspace(dto),
queryFn: async () => {
const { data } = await apiRequest.post<{
projects: (Workspace & { isMember: boolean })[];
projects: (Project & { isMember: boolean })[];
totalCount: number;
}>("/api/v1/workspace/search", dto);
}>("/api/v1/projects/search", dto);
return data;
},
@@ -181,17 +177,17 @@ export const useSearchProjects = ({ options, ...dto }: TSearchProjectsDTO) =>
});
const fetchUserWorkspaceMemberships = async (orgId: string) => {
const { data } = await apiRequest.get<Record<string, Workspace[]>>(
`/api/v1/organization/${orgId}/workspace-memberships`
const { data } = await apiRequest.get<Record<string, Project[]>>(
`/api/v1/organization/${orgId}/project-memberships`
);
return data;
};
// to get all userids in an org with the workspace they are part of
// to get all userids in an org with the project they are part of
export const useGetUserWorkspaceMemberships = (orgId: string) =>
useQuery({
queryKey: workspaceKeys.getWorkspaceMemberships(orgId),
queryKey: projectKeys.getWorkspaceMemberships(orgId),
queryFn: () => fetchUserWorkspaceMemberships(orgId),
enabled: Boolean(orgId)
});
@@ -200,62 +196,62 @@ export const useNameWorkspaceSecrets = () => {
const queryClient = useQueryClient();
return useMutation<object, object, NameWorkspaceSecretsDTO>({
mutationFn: async ({ workspaceId, secretsToUpdate }) =>
apiRequest.post(`/api/v3/workspaces/${workspaceId}/secrets/names`, {
mutationFn: async ({ projectId, secretsToUpdate }) =>
apiRequest.post(`/api/v3/projects/${projectId}/secrets/names`, {
secretsToUpdate
}),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIndexStatus(variables.workspaceId)
queryKey: projectKeys.getWorkspaceIndexStatus(variables.projectId)
});
}
});
};
const fetchWorkspaceAuthorization = async (workspaceId: string) => {
const fetchWorkspaceAuthorization = async (projectId: string) => {
const { data } = await apiRequest.get<{ authorizations: IntegrationAuth[] }>(
`/api/v1/workspace/${workspaceId}/authorizations`
`/api/v1/projects/${projectId}/authorizations`
);
return data.authorizations;
};
export const useGetWorkspaceAuthorizations = <TData = IntegrationAuth[],>(
workspaceId: string,
projectId: string,
select?: (data: IntegrationAuth[]) => TData
) =>
useQuery({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId),
queryFn: () => fetchWorkspaceAuthorization(workspaceId),
enabled: Boolean(workspaceId),
queryKey: projectKeys.getWorkspaceAuthorization(projectId),
queryFn: () => fetchWorkspaceAuthorization(projectId),
enabled: Boolean(projectId),
select
});
export const fetchWorkspaceIntegrations = async (workspaceId: string) => {
export const fetchWorkspaceIntegrations = async (projectId: string) => {
const { data } = await apiRequest.get<{ integrations: TIntegration[] }>(
`/api/v1/workspace/${workspaceId}/integrations`
`/api/v1/projects/${projectId}/integrations`
);
return data.integrations;
};
export const useGetWorkspaceIntegrations = (workspaceId: string) =>
export const useGetWorkspaceIntegrations = (projectId: string) =>
useQuery({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId),
queryFn: () => fetchWorkspaceIntegrations(workspaceId),
enabled: Boolean(workspaceId),
queryKey: projectKeys.getWorkspaceIntegrations(projectId),
queryFn: () => fetchWorkspaceIntegrations(projectId),
enabled: Boolean(projectId),
refetchInterval: 4000
});
export const createWorkspace = (
dto: CreateWorkspaceDTO
): Promise<{ data: { project: Workspace } }> => {
return apiRequest.post("/api/v2/workspace", dto);
): Promise<{ data: { project: Project } }> => {
return apiRequest.post("/api/v1/projects", dto);
};
export const useCreateWorkspace = () => {
const queryClient = useQueryClient();
return useMutation<{ data: { project: Workspace } }, object, CreateWorkspaceDTO>({
return useMutation<{ data: { project: Project } }, object, CreateWorkspaceDTO>({
mutationFn: async ({ projectName, projectDescription, kmsKeyId, template, type }) =>
createWorkspace({
projectName,
@@ -266,7 +262,7 @@ export const useCreateWorkspace = () => {
}),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -275,7 +271,7 @@ export const useCreateWorkspace = () => {
export const useUpdateProject = () => {
const queryClient = useQueryClient();
return useMutation<Workspace, object, UpdateProjectDTO>({
return useMutation<Project, object, UpdateProjectDTO>({
mutationFn: async ({
projectID,
newProjectName,
@@ -285,8 +281,8 @@ export const useUpdateProject = () => {
showSnapshotsLegacy,
secretDetectionIgnoreValues
}) => {
const { data } = await apiRequest.patch<{ workspace: Workspace }>(
`/api/v1/workspace/${projectID}`,
const { data } = await apiRequest.patch<{ project: Project }>(
`/api/v1/projects/${projectID}`,
{
name: newProjectName,
description: newProjectDescription,
@@ -296,10 +292,10 @@ export const useUpdateProject = () => {
secretDetectionIgnoreValues
}
);
return data.workspace;
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -307,18 +303,18 @@ export const useUpdateProject = () => {
export const useToggleAutoCapitalization = () => {
const queryClient = useQueryClient();
return useMutation<Workspace, object, ToggleAutoCapitalizationDTO>({
mutationFn: async ({ workspaceID, state }) => {
const { data } = await apiRequest.post<{ workspace: Workspace }>(
`/api/v1/workspace/${workspaceID}/auto-capitalization`,
return useMutation<Project, object, ToggleAutoCapitalizationDTO>({
mutationFn: async ({ projectID, state }) => {
const { data } = await apiRequest.post<{ project: Project }>(
`/api/v1/projects/${projectID}/auto-capitalization`,
{
autoCapitalization: state
}
);
return data.workspace;
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -326,18 +322,18 @@ export const useToggleAutoCapitalization = () => {
export const useToggleDeleteProjectProtection = () => {
const queryClient = useQueryClient();
return useMutation<Workspace, object, ToggleDeleteProjectProtectionDTO>({
mutationFn: async ({ workspaceID, state }) => {
const { data } = await apiRequest.post<{ workspace: Workspace }>(
`/api/v1/workspace/${workspaceID}/delete-protection`,
return useMutation<Project, object, ToggleDeleteProjectProtectionDTO>({
mutationFn: async ({ projectID, state }) => {
const { data } = await apiRequest.post<{ project: Project }>(
`/api/v1/projects/${projectID}/delete-protection`,
{
hasDeleteProtection: state
}
);
return data.workspace;
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -345,15 +341,15 @@ export const useToggleDeleteProjectProtection = () => {
export const useUpdateWorkspaceVersionLimit = () => {
const queryClient = useQueryClient();
return useMutation<Workspace, object, UpdatePitVersionLimitDTO>({
return useMutation<Project, object, UpdatePitVersionLimitDTO>({
mutationFn: async ({ projectSlug, pitVersionLimit }) => {
const { data } = await apiRequest.put(`/api/v1/workspace/${projectSlug}/version-limit`, {
const { data } = await apiRequest.put(`/api/v1/projects/${projectSlug}/version-limit`, {
pitVersionLimit
});
return data.workspace;
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -361,18 +357,18 @@ export const useUpdateWorkspaceVersionLimit = () => {
export const useUpdateWorkspaceAuditLogsRetention = () => {
const queryClient = useQueryClient();
return useMutation<Workspace, object, UpdateAuditLogsRetentionDTO>({
return useMutation<Project, object, UpdateAuditLogsRetentionDTO>({
mutationFn: async ({ projectSlug, auditLogsRetentionDays }) => {
const { data } = await apiRequest.put(
`/api/v1/workspace/${projectSlug}/audit-logs-retention`,
`/api/v1/projects/${projectSlug}/audit-logs-retention`,
{
auditLogsRetentionDays
}
);
return data.workspace;
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -380,13 +376,13 @@ export const useUpdateWorkspaceAuditLogsRetention = () => {
export const useDeleteWorkspace = () => {
const queryClient = useQueryClient();
return useMutation<Workspace, object, DeleteWorkspaceDTO>({
mutationFn: async ({ workspaceID }) => {
const { data } = await apiRequest.delete(`/api/v1/workspace/${workspaceID}`);
return data.workspace;
return useMutation<Project, object, DeleteWorkspaceDTO>({
mutationFn: async ({ projectID }) => {
const { data } = await apiRequest.delete(`/api/v1/projects/${projectID}`);
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({
queryKey: ["org-admin-projects"]
});
@@ -398,9 +394,9 @@ export const useCreateWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<WorkspaceEnv, WorkspaceEnv, CreateEnvironmentDTO>({
mutationFn: async ({ workspaceId, name, slug }) => {
mutationFn: async ({ projectId, name, slug }) => {
const { data } = await apiRequest.post<{ environment: WorkspaceEnv }>(
`/api/v1/workspace/${workspaceId}/environments`,
`/api/v1/projects/${projectId}/environments`,
{
name,
slug
@@ -410,7 +406,7 @@ export const useCreateWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -420,8 +416,8 @@ export const useUpdateWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<object, object, UpdateEnvironmentDTO>({
mutationFn: ({ workspaceId, id, name, slug, position }) => {
return apiRequest.patch(`/api/v1/workspace/${workspaceId}/environments/${id}`, {
mutationFn: ({ projectId, id, name, slug, position }) => {
return apiRequest.patch(`/api/v1/projects/${projectId}/environments/${id}`, {
name,
slug,
position
@@ -429,7 +425,7 @@ export const useUpdateWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -439,57 +435,54 @@ export const useDeleteWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<object, object, DeleteEnvironmentDTO>({
mutationFn: ({ id, workspaceId }) => {
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/environments/${id}`);
mutationFn: ({ id, projectId }) => {
return apiRequest.delete(`/api/v1/projects/${projectId}/environments/${id}`);
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserWorkspace()
});
}
});
};
export const useGetWorkspaceUsers = (
workspaceId: string,
projectId: string,
includeGroupMembers?: boolean,
roles?: string[]
) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceUsers(workspaceId, includeGroupMembers, roles),
queryKey: projectKeys.getWorkspaceUsers(projectId, includeGroupMembers, roles),
queryFn: async () => {
const {
data: { users }
} = await apiRequest.get<{ users: TWorkspaceUser[] }>(
`/api/v1/workspace/${workspaceId}/users`,
{
params: {
includeGroupMembers,
roles:
roles && roles.length > 0
? roles.map((role) => encodeURIComponent(role)).join(",")
: undefined
}
} = await apiRequest.get<{ users: TWorkspaceUser[] }>(`/api/v1/projects/${projectId}/users`, {
params: {
includeGroupMembers,
roles:
roles && roles.length > 0
? roles.map((role) => encodeURIComponent(role)).join(",")
: undefined
}
);
});
return users;
},
enabled: true
});
};
export const useGetWorkspaceUserDetails = (workspaceId: string, membershipId: string) => {
export const useGetWorkspaceUserDetails = (projectId: string, membershipId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId),
queryKey: projectKeys.getWorkspaceUserDetails(projectId, membershipId),
queryFn: async () => {
const {
data: { membership }
} = await apiRequest.get<{ membership: TWorkspaceUser }>(
`/api/v1/workspace/${workspaceId}/memberships/${membershipId}`
`/api/v1/projects/${projectId}/memberships/${membershipId}`
);
return membership;
},
enabled: Boolean(workspaceId) && Boolean(membershipId)
enabled: Boolean(projectId) && Boolean(membershipId)
});
};
@@ -499,21 +492,21 @@ export const useDeleteUserFromWorkspace = () => {
return useMutation({
mutationFn: async ({
usernames,
workspaceId
projectId
}: {
workspaceId: string;
projectId: string;
usernames: string[];
orgId: string;
}) => {
const {
data: { deletedMembership }
} = await apiRequest.delete(`/api/v2/workspace/${workspaceId}/memberships`, {
} = await apiRequest.delete(`/api/v1/projects/${projectId}/memberships`, {
data: { usernames }
});
return deletedMembership;
},
onSuccess: (_, { orgId, workspaceId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
onSuccess: (_, { orgId, projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});
@@ -524,21 +517,21 @@ export const useDeleteUserFromWorkspace = () => {
export const useUpdateUserWorkspaceRole = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({ membershipId, roles, workspaceId }: TUpdateWorkspaceUserRoleDTO) => {
mutationFn: async ({ membershipId, roles, projectId }: TUpdateWorkspaceUserRoleDTO) => {
const {
data: { membership }
} = await apiRequest.patch<{ membership: { projectId: string } }>(
`/api/v1/workspace/${workspaceId}/memberships/${membershipId}`,
`/api/v1/projects/${projectId}/memberships/${membershipId}`,
{
roles
}
);
return membership;
},
onSuccess: (_, { workspaceId, membershipId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
onSuccess: (_, { projectId, membershipId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId)
queryKey: projectKeys.getWorkspaceUserDetails(projectId, membershipId)
});
}
});
@@ -549,17 +542,17 @@ export const useAddIdentityToWorkspace = () => {
return useMutation({
mutationFn: async ({
identityId,
workspaceId,
projectId,
role
}: {
identityId: string;
workspaceId: string;
projectId: string;
role?: string;
}) => {
const {
data: { identityMembership }
} = await apiRequest.post(
`/api/v2/workspace/${workspaceId}/identity-memberships/${identityId}`,
`/api/v1/projects/${projectId}/identity-memberships/${identityId}`,
{
role
}
@@ -567,9 +560,9 @@ export const useAddIdentityToWorkspace = () => {
return identityMembership;
},
onSuccess: (_, { identityId, workspaceId }) => {
onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
@@ -581,11 +574,11 @@ export const useAddIdentityToWorkspace = () => {
export const useUpdateIdentityWorkspaceRole = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({ identityId, workspaceId, roles }: TUpdateWorkspaceIdentityRoleDTO) => {
mutationFn: async ({ identityId, projectId, roles }: TUpdateWorkspaceIdentityRoleDTO) => {
const {
data: { identityMembership }
} = await apiRequest.patch(
`/api/v2/workspace/${workspaceId}/identity-memberships/${identityId}`,
`/api/v1/projects/${projectId}/identity-memberships/${identityId}`,
{
roles
}
@@ -593,15 +586,15 @@ export const useUpdateIdentityWorkspaceRole = () => {
return identityMembership;
},
onSuccess: (_, { identityId, workspaceId }) => {
onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIdentityMembershipDetails(workspaceId, identityId)
queryKey: projectKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId)
});
}
});
@@ -610,23 +603,17 @@ export const useUpdateIdentityWorkspaceRole = () => {
export const useDeleteIdentityFromWorkspace = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
identityId,
workspaceId
}: {
identityId: string;
workspaceId: string;
}) => {
mutationFn: async ({ identityId, projectId }: { identityId: string; projectId: string }) => {
const {
data: { identityMembership }
} = await apiRequest.delete(
`/api/v2/workspace/${workspaceId}/identity-memberships/${identityId}`
`/api/v1/projects/${projectId}/identity-memberships/${identityId}`
);
return identityMembership;
},
onSuccess: (_, { identityId, workspaceId }) => {
onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
@@ -637,7 +624,7 @@ export const useDeleteIdentityFromWorkspace = () => {
export const useGetWorkspaceIdentityMemberships = (
{
workspaceId,
projectId,
offset = 0,
limit = 100,
orderBy = ProjectIdentityOrderBy.Name,
@@ -649,14 +636,14 @@ export const useGetWorkspaceIdentityMemberships = (
TProjectIdentitiesList,
unknown,
TProjectIdentitiesList,
ReturnType<typeof workspaceKeys.getWorkspaceIdentityMembershipsWithParams>
ReturnType<typeof projectKeys.getWorkspaceIdentityMembershipsWithParams>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceIdentityMembershipsWithParams({
workspaceId,
queryKey: projectKeys.getWorkspaceIdentityMembershipsWithParams({
projectId,
offset,
limit,
orderBy,
@@ -673,7 +660,7 @@ export const useGetWorkspaceIdentityMemberships = (
});
const { data } = await apiRequest.get<TProjectIdentitiesList>(
`/api/v2/workspace/${workspaceId}/identity-memberships`,
`/api/v1/projects/${projectId}/identity-memberships`,
{ params }
);
return data;
@@ -686,12 +673,12 @@ export const useGetWorkspaceIdentityMemberships = (
export const useGetWorkspaceIdentityMembershipDetails = (projectId: string, identityId: string) => {
return useQuery({
enabled: Boolean(projectId && identityId),
queryKey: workspaceKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId),
queryKey: projectKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId),
queryFn: async () => {
const {
data: { identityMembership }
} = await apiRequest.get<{ identityMembership: IdentityMembership }>(
`/api/v2/workspace/${projectId}/identity-memberships/${identityId}`
`/api/v1/projects/${projectId}/identity-memberships/${identityId}`
);
return identityMembership;
}
@@ -701,12 +688,12 @@ export const useGetWorkspaceIdentityMembershipDetails = (projectId: string, iden
export const useGetWorkspaceGroupMembershipDetails = (projectId: string, groupId: string) => {
return useQuery({
enabled: Boolean(projectId && groupId),
queryKey: workspaceKeys.getWorkspaceGroupMembershipDetails(projectId, groupId),
queryKey: projectKeys.getWorkspaceGroupMembershipDetails(projectId, groupId),
queryFn: async () => {
const {
data: { groupMembership }
} = await apiRequest.get<{ groupMembership: TGroupMembership }>(
`/api/v2/workspace/${projectId}/groups/${groupId}`
`/api/v1/projects/${projectId}/groups/${groupId}`
);
return groupMembership;
}
@@ -715,12 +702,12 @@ export const useGetWorkspaceGroupMembershipDetails = (projectId: string, groupId
export const useListWorkspaceGroups = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId),
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId),
queryFn: async () => {
const {
data: { groupMemberships }
} = await apiRequest.get<{ groupMemberships: TGroupMembership[] }>(
`/api/v2/workspace/${projectId}/groups`
`/api/v1/projects/${projectId}/groups`
);
return groupMemberships;
},
@@ -736,7 +723,7 @@ export const useListWorkspaceCas = ({
status?: CaStatus;
}) => {
return useQuery({
queryKey: workspaceKeys.specificWorkspaceCas({
queryKey: projectKeys.specificWorkspaceCas({
projectSlug,
status
}),
@@ -748,7 +735,7 @@ export const useListWorkspaceCas = ({
const {
data: { cas }
} = await apiRequest.get<{ cas: TCertificateAuthority[] }>(
`/api/v2/workspace/${projectSlug}/cas`,
`/api/v1/projects/${projectSlug}/cas`,
{
params
}
@@ -769,7 +756,7 @@ export const useListWorkspaceCertificates = ({
limit: number;
}) => {
return useQuery({
queryKey: workspaceKeys.specificWorkspaceCertificates({
queryKey: projectKeys.specificWorkspaceCertificates({
slug: projectSlug,
offset,
limit
@@ -783,7 +770,7 @@ export const useListWorkspaceCertificates = ({
const {
data: { certificates, totalCount }
} = await apiRequest.get<{ certificates: TCertificate[]; totalCount: number }>(
`/api/v2/workspace/${projectSlug}/certificates`,
`/api/v1/projects/${projectSlug}/certificates`,
{
params
}
@@ -795,51 +782,49 @@ export const useListWorkspaceCertificates = ({
});
};
export const useListWorkspacePkiAlerts = ({ workspaceId }: { workspaceId: string }) => {
export const useListWorkspacePkiAlerts = ({ projectId }: { projectId: string }) => {
return useQuery({
queryKey: workspaceKeys.getWorkspacePkiAlerts(workspaceId),
queryKey: projectKeys.getWorkspacePkiAlerts(projectId),
queryFn: async () => {
const {
data: { alerts }
} = await apiRequest.get<{ alerts: TPkiAlert[] }>(
`/api/v2/workspace/${workspaceId}/pki-alerts`
);
} = await apiRequest.get<{ alerts: TPkiAlert[] }>(`/api/v1/projects/${projectId}/pki-alerts`);
return { alerts };
},
enabled: Boolean(workspaceId)
enabled: Boolean(projectId)
});
};
export const useListWorkspacePkiCollections = ({ workspaceId }: { workspaceId: string }) => {
export const useListWorkspacePkiCollections = ({ projectId }: { projectId: string }) => {
return useQuery({
queryKey: workspaceKeys.getWorkspacePkiCollections(workspaceId),
queryKey: projectKeys.getWorkspacePkiCollections(projectId),
queryFn: async () => {
const {
data: { collections }
} = await apiRequest.get<{ collections: TPkiCollection[] }>(
`/api/v2/workspace/${workspaceId}/pki-collections`
`/api/v1/projects/${projectId}/pki-collections`
);
return { collections };
},
enabled: Boolean(workspaceId)
enabled: Boolean(projectId)
});
};
export const useListWorkspaceCertificateTemplates = ({ workspaceId }: { workspaceId: string }) => {
export const useListWorkspaceCertificateTemplates = ({ projectId }: { projectId: string }) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(workspaceId),
queryKey: projectKeys.getWorkspaceCertificateTemplates(projectId),
queryFn: async () => {
const {
data: { certificateTemplates }
} = await apiRequest.get<{ certificateTemplates: TCertificateTemplate[] }>(
`/api/v2/workspace/${workspaceId}/certificate-templates`
`/api/v1/projects/${projectId}/certificate-templates`
);
return { certificateTemplates };
},
enabled: Boolean(workspaceId)
enabled: Boolean(projectId)
});
};
@@ -853,7 +838,7 @@ export const useListWorkspaceSshCertificates = ({
projectId: string;
}) => {
return useQuery({
queryKey: workspaceKeys.specificWorkspaceSshCertificates({
queryKey: projectKeys.specificWorkspaceSshCertificates({
offset,
limit,
projectId
@@ -867,7 +852,7 @@ export const useListWorkspaceSshCertificates = ({
const { data } = await apiRequest.get<{
certificates: TSshCertificate[];
totalCount: number;
}>(`/api/v2/workspace/${projectId}/ssh-certificates`, {
}>(`/api/v1/projects/${projectId}/ssh-certificates`, {
params
});
return data;
@@ -878,12 +863,12 @@ export const useListWorkspaceSshCertificates = ({
export const useListWorkspaceSshCas = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceSshCas(projectId),
queryKey: projectKeys.getWorkspaceSshCas(projectId),
queryFn: async () => {
const {
data: { cas }
} = await apiRequest.get<{ cas: Omit<TSshCertificateAuthority, "publicKey">[] }>(
`/api/v2/workspace/${projectId}/ssh-cas`
`/api/v1/projects/${projectId}/ssh-cas`
);
return cas;
},
@@ -893,11 +878,11 @@ export const useListWorkspaceSshCas = (projectId: string) => {
export const useListWorkspaceSshHosts = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceSshHosts(projectId),
queryKey: projectKeys.getWorkspaceSshHosts(projectId),
queryFn: async () => {
const {
data: { hosts }
} = await apiRequest.get<{ hosts: TSshHost[] }>(`/api/v2/workspace/${projectId}/ssh-hosts`);
} = await apiRequest.get<{ hosts: TSshHost[] }>(`/api/v1/projects/${projectId}/ssh-hosts`);
return hosts;
},
enabled: Boolean(projectId)
@@ -906,12 +891,12 @@ export const useListWorkspaceSshHosts = (projectId: string) => {
export const useListWorkspacePkiSubscribers = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId),
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId),
queryFn: async () => {
const {
data: { subscribers }
} = await apiRequest.get<{ subscribers: TPkiSubscriber[] }>(
`/api/v2/workspace/${projectId}/pki-subscribers`
`/api/v1/projects/${projectId}/pki-subscribers`
);
return subscribers;
},
@@ -921,12 +906,12 @@ export const useListWorkspacePkiSubscribers = (projectId: string) => {
export const useListWorkspaceSshHostGroups = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId),
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId),
queryFn: async () => {
const {
data: { groups }
} = await apiRequest.get<{ groups: (TSshHostGroup & { hostCount: number })[] }>(
`/api/v2/workspace/${projectId}/ssh-host-groups`
`/api/v1/projects/${projectId}/ssh-host-groups`
);
return groups;
},
@@ -936,10 +921,10 @@ export const useListWorkspaceSshHostGroups = (projectId: string) => {
export const useListWorkspaceSshCertificateTemplates = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceSshCertificateTemplates(projectId),
queryKey: projectKeys.getWorkspaceSshCertificateTemplates(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<{ certificateTemplates: TSshCertificateTemplate[] }>(
`/api/v2/workspace/${projectId}/ssh-certificate-templates`
`/api/v1/projects/${projectId}/ssh-certificate-templates`
);
return data;
},
@@ -948,18 +933,18 @@ export const useListWorkspaceSshCertificateTemplates = (projectId: string) => {
};
export const useGetWorkspaceWorkflowIntegrationConfig = ({
workspaceId,
projectId,
integration
}: {
workspaceId: string;
projectId: string;
integration: WorkflowIntegrationPlatform;
}) => {
return useQuery({
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration),
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration),
queryFn: async () => {
const { data } = await apiRequest
.get<ProjectWorkflowIntegrationConfig>(
`/api/v1/workspace/${workspaceId}/workflow-integration-config/${integration}`
`/api/v1/projects/${projectId}/workflow-integration-config/${integration}`
)
.catch((err) => {
if (err.response.status === 404) {
@@ -971,16 +956,16 @@ export const useGetWorkspaceWorkflowIntegrationConfig = ({
return data;
},
enabled: Boolean(workspaceId)
enabled: Boolean(projectId)
});
};
export const useGetProjectSshConfig = (projectId: string) => {
return useQuery({
queryKey: workspaceKeys.getProjectSshConfig(projectId),
queryKey: projectKeys.getProjectSshConfig(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<TProjectSshConfig>(
`/api/v1/workspace/${projectId}/ssh-config`
`/api/v1/projects/${projectId}/ssh-config`
);
return data;
+42 -46
View File
@@ -3,47 +3,44 @@ import { TListProjectIdentitiesDTO, TSearchProjectsDTO } from "@app/hooks/api/wo
import type { CaStatus } from "../ca";
import { WorkflowIntegrationPlatform } from "../workflowIntegrations/types";
export const workspaceKeys = {
getWorkspaceById: (workspaceId: string) => ["workspaces", { workspaceId }] as const,
getWorkspaceSecrets: (workspaceId: string) => [{ workspaceId }, "workspace-secrets"] as const,
getWorkspaceIndexStatus: (workspaceId: string) =>
[{ workspaceId }, "workspace-index-status"] as const,
getProjectUpgradeStatus: (workspaceId: string) => [{ workspaceId }, "workspace-upgrade-status"],
getWorkspaceMemberships: (orgId: string) => [{ orgId }, "workspace-memberships"],
getWorkspaceAuthorization: (workspaceId: string) => [{ workspaceId }, "workspace-authorizations"],
getWorkspaceIntegrations: (workspaceId: string) => [{ workspaceId }, "workspace-integrations"],
getAllUserWorkspace: () => ["workspaces"] as const,
getWorkspaceAuditLogs: (workspaceId: string) =>
[{ workspaceId }, "workspace-audit-logs"] as const,
export const projectKeys = {
getWorkspaceById: (projectId: string) => ["projects", { projectId }] as const,
getWorkspaceSecrets: (projectId: string) => [{ projectId }, "project-secrets"] as const,
getWorkspaceIndexStatus: (projectId: string) => [{ projectId }, "project-index-status"] as const,
getProjectUpgradeStatus: (projectId: string) => [{ projectId }, "project-upgrade-status"],
getWorkspaceMemberships: (orgId: string) => [{ orgId }, "project-memberships"],
getWorkspaceAuthorization: (projectId: string) => [{ projectId }, "project-authorizations"],
getWorkspaceIntegrations: (projectId: string) => [{ projectId }, "project-integrations"],
getAllUserWorkspace: () => ["projects"] as const,
getWorkspaceAuditLogs: (projectId: string) => [{ projectId }, "project-audit-logs"] as const,
getWorkspaceUsers: (
workspaceId: string,
projectId: string,
includeGroupMembers: boolean = false,
roles: string[] = []
) => [{ workspaceId, includeGroupMembers, roles }, "workspace-users"] as const,
getWorkspaceUserDetails: (workspaceId: string, membershipId: string) =>
[{ workspaceId, membershipId }, "workspace-user-details"] as const,
getWorkspaceIdentityMemberships: (workspaceId: string) =>
[{ workspaceId }, "workspace-identity-memberships"] as const,
getWorkspaceIdentityMembershipDetails: (workspaceId: string, identityId: string) =>
[{ workspaceId, identityId }, "workspace-identity-membership-details"] as const,
) => [{ projectId, includeGroupMembers, roles }, "project-users"] as const,
getWorkspaceUserDetails: (projectId: string, membershipId: string) =>
[{ projectId, membershipId }, "project-user-details"] as const,
getWorkspaceIdentityMemberships: (projectId: string) =>
[{ projectId }, "project-identity-memberships"] as const,
getWorkspaceIdentityMembershipDetails: (projectId: string, identityId: string) =>
[{ projectId, identityId }, "project-identity-membership-details"] as const,
// allows invalidation using above key without knowing params
getWorkspaceIdentityMembershipsWithParams: ({
workspaceId,
projectId,
...params
}: TListProjectIdentitiesDTO) =>
[...workspaceKeys.getWorkspaceIdentityMemberships(workspaceId), params] as const,
[...projectKeys.getWorkspaceIdentityMemberships(projectId), params] as const,
searchWorkspace: (dto: TSearchProjectsDTO) => ["search-projects", dto] as const,
getWorkspaceGroupMemberships: (workspaceId: string) =>
[{ workspaceId }, "workspace-groups"] as const,
getWorkspaceGroupMembershipDetails: (workspaceId: string, groupId: string) =>
[{ workspaceId, groupId }, "workspace-group-membership-details"] as const,
getWorkspaceGroupMemberships: (projectId: string) => [{ projectId }, "project-groups"] as const,
getWorkspaceGroupMembershipDetails: (projectId: string, groupId: string) =>
[{ projectId, groupId }, "project-group-membership-details"] as const,
getWorkspaceCas: ({ projectSlug }: { projectSlug: string }) =>
[{ projectSlug }, "workspace-cas"] as const,
[{ projectSlug }, "project-cas"] as const,
specificWorkspaceCas: ({ projectSlug, status }: { projectSlug: string; status?: CaStatus }) =>
[...workspaceKeys.getWorkspaceCas({ projectSlug }), { status }] as const,
allWorkspaceCertificates: () => ["workspace-certificates"] as const,
[...projectKeys.getWorkspaceCas({ projectSlug }), { status }] as const,
allWorkspaceCertificates: () => ["project-certificates"] as const,
forWorkspaceCertificates: (slug: string) =>
[...workspaceKeys.allWorkspaceCertificates(), slug] as const,
[...projectKeys.allWorkspaceCertificates(), slug] as const,
specificWorkspaceCertificates: ({
slug,
offset,
@@ -52,25 +49,24 @@ export const workspaceKeys = {
slug: string;
offset: number;
limit: number;
}) => [...workspaceKeys.forWorkspaceCertificates(slug), { offset, limit }] as const,
getWorkspacePkiAlerts: (workspaceId: string) =>
[{ workspaceId }, "workspace-pki-alerts"] as const,
}) => [...projectKeys.forWorkspaceCertificates(slug), { offset, limit }] as const,
getWorkspacePkiAlerts: (projectId: string) => [{ projectId }, "project-pki-alerts"] as const,
getWorkspacePkiSubscribers: (projectId: string) =>
[{ projectId }, "workspace-pki-subscribers"] as const,
getWorkspacePkiCollections: (workspaceId: string) =>
[{ workspaceId }, "workspace-pki-collections"] as const,
getWorkspaceCertificateTemplates: (workspaceId: string) =>
[{ workspaceId }, "workspace-certificate-templates"] as const,
[{ projectId }, "project-pki-subscribers"] as const,
getWorkspacePkiCollections: (projectId: string) =>
[{ projectId }, "project-pki-collections"] as const,
getWorkspaceCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-certificate-templates"] as const,
getWorkspaceWorkflowIntegrationConfig: (
workspaceId: string,
projectId: string,
integration: WorkflowIntegrationPlatform
) => [{ workspaceId, integration }, "workspace-workflow-integration-config"] as const,
getWorkspaceSshCas: (projectId: string) => [{ projectId }, "workspace-ssh-cas"] as const,
) => [{ projectId, integration }, "project-workflow-integration-config"] as const,
getWorkspaceSshCas: (projectId: string) => [{ projectId }, "project-ssh-cas"] as const,
allWorkspaceSshCertificates: (projectId: string) =>
[{ projectId }, "workspace-ssh-certificates"] as const,
getWorkspaceSshHosts: (projectId: string) => [{ projectId }, "workspace-ssh-hosts"] as const,
[{ projectId }, "project-ssh-certificates"] as const,
getWorkspaceSshHosts: (projectId: string) => [{ projectId }, "project-ssh-hosts"] as const,
getWorkspaceSshHostGroups: (projectId: string) =>
[{ projectId }, "workspace-ssh-host-groups"] as const,
[{ projectId }, "project-ssh-host-groups"] as const,
specificWorkspaceSshCertificates: ({
offset,
limit,
@@ -79,8 +75,8 @@ export const workspaceKeys = {
offset: number;
limit: number;
projectId: string;
}) => [...workspaceKeys.allWorkspaceSshCertificates(projectId), { offset, limit }] as const,
}) => [...projectKeys.allWorkspaceSshCertificates(projectId), { offset, limit }] as const,
getWorkspaceSshCertificateTemplates: (projectId: string) =>
[{ projectId }, "workspace-ssh-certificate-templates"] as const,
[{ projectId }, "project-ssh-certificate-templates"] as const,
getProjectSshConfig: (projectId: string) => [{ projectId }, "project-ssh-config"] as const
};
+12 -12
View File
@@ -20,7 +20,7 @@ export enum ProjectUserMembershipTemporaryMode {
Relative = "relative"
}
export type Workspace = {
export type Project = {
__v: number;
id: string;
name: string;
@@ -52,7 +52,7 @@ export type WorkspaceEnv = {
export type WorkspaceTag = { id: string; name: string; slug: string };
export type NameWorkspaceSecretsDTO = {
workspaceId: string;
projectId: string;
secretsToUpdate: {
secretName: string;
secretId: string;
@@ -87,19 +87,19 @@ export type UpdateProjectDTO = {
export type UpdatePitVersionLimitDTO = { projectSlug: string; pitVersionLimit: number };
export type UpdateAuditLogsRetentionDTO = { projectSlug: string; auditLogsRetentionDays: number };
export type ToggleAutoCapitalizationDTO = { workspaceID: string; state: boolean };
export type ToggleDeleteProjectProtectionDTO = { workspaceID: string; state: boolean };
export type ToggleAutoCapitalizationDTO = { projectID: string; state: boolean };
export type ToggleDeleteProjectProtectionDTO = { projectID: string; state: boolean };
export type DeleteWorkspaceDTO = { workspaceID: string };
export type DeleteWorkspaceDTO = { projectID: string };
export type CreateEnvironmentDTO = {
workspaceId: string;
projectId: string;
name: string;
slug: string;
};
export type ReorderEnvironmentsDTO = {
workspaceId: string;
projectId: string;
environmentSlug: string;
environmentName: string;
otherEnvironmentSlug: string;
@@ -107,18 +107,18 @@ export type ReorderEnvironmentsDTO = {
};
export type UpdateEnvironmentDTO = {
workspaceId: string;
projectId: string;
id: string;
name?: string;
slug?: string;
position?: number;
};
export type DeleteEnvironmentDTO = { workspaceId: string; id: string };
export type DeleteEnvironmentDTO = { projectId: string; id: string };
export type TUpdateWorkspaceUserRoleDTO = {
membershipId: string;
workspaceId: string;
projectId: string;
roles: (
| {
role: string;
@@ -136,7 +136,7 @@ export type TUpdateWorkspaceUserRoleDTO = {
export type TUpdateWorkspaceIdentityRoleDTO = {
identityId: string;
workspaceId: string;
projectId: string;
roles: (
| {
role: string;
@@ -171,7 +171,7 @@ export type TUpdateWorkspaceGroupRoleDTO = {
};
export type TListProjectIdentitiesDTO = {
workspaceId: string;
projectId: string;
offset?: number;
limit?: number;
orderBy?: ProjectIdentityOrderBy;
@@ -36,7 +36,7 @@ import { usePopUp } from "@app/hooks";
import { useGetUserWorkspaces } from "@app/hooks/api";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
import { Workspace } from "@app/hooks/api/workspace/types";
import { Project } from "@app/hooks/api/workspace/types";
export const ProjectSelect = () => {
const [searchProject, setSearchProject] = useState("");
@@ -88,7 +88,7 @@ export const ProjectSelect = () => {
const projects = useMemo(() => {
const projectOptions = workspaces
.map((w): Workspace & { isFavorite: boolean } => ({
.map((w): Project & { isFavorite: boolean } => ({
...w,
isFavorite: Boolean(projectFavorites?.includes(w.id))
}))
@@ -29,7 +29,7 @@ import {
} from "@app/hooks/api/auditLogs/constants";
import { EventType } from "@app/hooks/api/auditLogs/enums";
import { UserAgentType } from "@app/hooks/api/auth/types";
import { Workspace } from "@app/hooks/api/workspace/types";
import { Project } from "@app/hooks/api/workspace/types";
import { LogFilterItem } from "./LogFilterItem";
import { auditLogFilterFormSchema, Presets, TAuditLogFilterFormData } from "./types";
@@ -44,7 +44,7 @@ type Props = {
presets?: Presets;
setFilter: (data: TAuditLogFilterFormData) => void;
filter: TAuditLogFilterFormData;
project?: Workspace;
project?: Project;
};
const getActiveFilterCount = (filter: TAuditLogFilterFormData) => {
@@ -13,7 +13,7 @@ import {
} from "@app/context";
import { Timezone } from "@app/helpers/datetime";
import { withPermission, withProjectPermission } from "@app/hoc";
import { Workspace } from "@app/hooks/api/workspace/types";
import { Project } from "@app/hooks/api/workspace/types";
import { usePopUp } from "@app/hooks/usePopUp";
import { LogsDateFilter } from "./LogsDateFilter";
@@ -31,7 +31,7 @@ type Props = {
refetchInterval?: number;
showFilters?: boolean;
pageView?: boolean;
project?: Workspace;
project?: Project;
};
const LogsSectionComponent = ({
@@ -48,7 +48,7 @@ import {
useRequestProjectAccess,
useSearchProjects
} from "@app/hooks/api";
import { ProjectType, Workspace, WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectType, Project, WorkspaceEnv } from "@app/hooks/api/workspace/types";
import {
ProjectListToggle,
ProjectListView
@@ -180,7 +180,7 @@ export const AllProjectView = ({
offset,
totalCount: searchedProjects?.totalCount || 0
});
const requestedWorkspaceDetails = (popUp.requestAccessConfirmation.data || {}) as Workspace;
const requestedWorkspaceDetails = (popUp.requestAccessConfirmation.data || {}) as Project;
const handleToggleFilterByProjectType = (el: ProjectType) =>
setProjectTypeFilter((state) => (state === el ? undefined : el));
@@ -43,7 +43,7 @@ import { useGetUserWorkspaces } from "@app/hooks/api";
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
import { ProjectType, Workspace } from "@app/hooks/api/workspace/types";
import { ProjectType, Project } from "@app/hooks/api/workspace/types";
import {
ProjectListToggle,
ProjectListView
@@ -136,7 +136,7 @@ export const MyProjectView = ({
const { workspacesWithFaveProp } = useMemo(() => {
const workspacesWithFav = filteredWorkspaces
.map((w): Workspace & { isFavorite: boolean } => ({
.map((w): Project & { isFavorite: boolean } => ({
...w,
isFavorite: Boolean(projectFavorites?.includes(w.id))
}))
@@ -188,7 +188,7 @@ export const MyProjectView = ({
}
};
const renderProjectGridItem = (workspace: Workspace, isFavorite: boolean) => (
const renderProjectGridItem = (workspace: Project, isFavorite: boolean) => (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div
onClick={() => {
@@ -242,7 +242,7 @@ export const MyProjectView = ({
</p>
</div>
);
const renderProjectListItem = (workspace: Workspace, isFavorite: boolean, index: number) => (
const renderProjectListItem = (workspace: Project, isFavorite: boolean, index: number) => (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div
onClick={() => {
@@ -120,7 +120,7 @@ export const RollbackPreviewTab = (): JSX.Element => {
] as const);
const { mutateAsync: rollback } = useCommitRollback({
workspaceId: currentWorkspace.id,
projectId: currentWorkspace.id,
commitId: selectedCommitId,
folderId,
deepRollback,
@@ -414,7 +414,7 @@ export const SecretListView = ({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -492,7 +492,7 @@ export const SecretListView = ({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })