mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 14:26:38 +00:00
feat: migrated secret router
This commit is contained in:
@@ -33,18 +33,18 @@ export const useCreateSecretV3 = ({
|
||||
secretPath = "/",
|
||||
type,
|
||||
environment,
|
||||
workspaceId,
|
||||
projectId,
|
||||
secretKey,
|
||||
secretValue,
|
||||
secretComment,
|
||||
skipMultilineEncoding,
|
||||
tagIds
|
||||
}) => {
|
||||
const { data } = await apiRequest.post(`/api/v3/secrets/raw/${secretKey}`, {
|
||||
const { data } = await apiRequest.post(`/api/v4/secrets/${secretKey}`, {
|
||||
secretPath,
|
||||
type,
|
||||
environment,
|
||||
workspaceId,
|
||||
projectId,
|
||||
secretValue,
|
||||
secretComment,
|
||||
skipMultilineEncoding,
|
||||
@@ -52,26 +52,26 @@ export const useCreateSecretV3 = ({
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -88,7 +88,7 @@ export const useUpdateSecretV3 = ({
|
||||
secretPath = "/",
|
||||
type,
|
||||
environment,
|
||||
workspaceId,
|
||||
projectId,
|
||||
secretKey,
|
||||
secretValue,
|
||||
tagIds,
|
||||
@@ -100,8 +100,8 @@ export const useUpdateSecretV3 = ({
|
||||
skipMultilineEncoding,
|
||||
secretMetadata
|
||||
}) => {
|
||||
const { data } = await apiRequest.patch(`/api/v3/secrets/raw/${secretKey}`, {
|
||||
workspaceId,
|
||||
const { data } = await apiRequest.patch(`/api/v4/secrets/${secretKey}`, {
|
||||
projectId,
|
||||
environment,
|
||||
type,
|
||||
secretReminderNote,
|
||||
@@ -117,26 +117,26 @@ export const useUpdateSecretV3 = ({
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -150,17 +150,10 @@ export const useDeleteSecretV3 = ({
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TDeleteSecretsV3DTO>({
|
||||
mutationFn: async ({
|
||||
secretPath = "/",
|
||||
type,
|
||||
environment,
|
||||
workspaceId,
|
||||
secretKey,
|
||||
secretId
|
||||
}) => {
|
||||
const { data } = await apiRequest.delete(`/api/v3/secrets/raw/${secretKey}`, {
|
||||
mutationFn: async ({ secretPath = "/", type, environment, projectId, secretKey, secretId }) => {
|
||||
const { data } = await apiRequest.delete(`/api/v4/secrets/${secretKey}`, {
|
||||
data: {
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
type,
|
||||
secretPath,
|
||||
@@ -169,26 +162,26 @@ export const useDeleteSecretV3 = ({
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -202,35 +195,35 @@ export const useCreateSecretBatch = ({
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TCreateSecretBatchDTO>({
|
||||
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.post("/api/v3/secrets/batch/raw", {
|
||||
workspaceId,
|
||||
mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.post("/api/v4/secrets/batch", {
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
secrets
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -244,35 +237,35 @@ export const useUpdateSecretBatch = ({
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TUpdateSecretBatchDTO>({
|
||||
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.patch("/api/v3/secrets/batch/raw", {
|
||||
workspaceId,
|
||||
mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.patch("/api/v4/secrets/batch", {
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
secrets
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -286,10 +279,10 @@ export const useDeleteSecretBatch = ({
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, TDeleteSecretBatchDTO>({
|
||||
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.delete("/api/v3/secrets/batch/raw", {
|
||||
mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
|
||||
const { data } = await apiRequest.delete("/api/v4/secrets/batch", {
|
||||
data: {
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
secrets
|
||||
@@ -297,26 +290,26 @@ export const useDeleteSecretBatch = ({
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
},
|
||||
...options
|
||||
});
|
||||
@@ -349,7 +342,7 @@ export const useMoveSecrets = ({
|
||||
const { data } = await apiRequest.post<{
|
||||
isSourceUpdated: boolean;
|
||||
isDestinationUpdated: boolean;
|
||||
}>("/api/v3/secrets/move", {
|
||||
}>("/api/v4/secrets/move", {
|
||||
sourceEnvironment,
|
||||
sourceSecretPath,
|
||||
projectSlug,
|
||||
@@ -370,7 +363,7 @@ export const useMoveSecrets = ({
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({
|
||||
workspaceId: projectId,
|
||||
projectId,
|
||||
environment: sourceEnvironment,
|
||||
secretPath: sourceSecretPath
|
||||
})
|
||||
@@ -378,33 +371,33 @@ export const useMoveSecrets = ({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({
|
||||
environment: sourceEnvironment,
|
||||
workspaceId: projectId,
|
||||
projectId,
|
||||
directory: sourceSecretPath
|
||||
})
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({
|
||||
environment: sourceEnvironment,
|
||||
workspaceId: projectId,
|
||||
projectId,
|
||||
directory: sourceSecretPath
|
||||
})
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({
|
||||
projectId: projectId,
|
||||
projectId,
|
||||
environment: sourceEnvironment,
|
||||
directory: sourceSecretPath
|
||||
})
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({
|
||||
workspaceId: projectId,
|
||||
projectId,
|
||||
environment: sourceEnvironment,
|
||||
directory: sourceSecretPath
|
||||
})
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretApprovalRequestKeys.count({ workspaceId: projectId })
|
||||
queryKey: secretApprovalRequestKeys.count({ projectId })
|
||||
});
|
||||
},
|
||||
...options
|
||||
@@ -432,16 +425,16 @@ export const useCreateCommit = () => {
|
||||
object,
|
||||
object,
|
||||
{
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
pendingChanges: PendingChanges;
|
||||
message: string;
|
||||
}
|
||||
>({
|
||||
mutationFn: async ({ workspaceId, environment, secretPath, pendingChanges, message }) => {
|
||||
mutationFn: async ({ projectId, environment, secretPath, pendingChanges, message }) => {
|
||||
const { data } = await apiRequest.post("/api/v1/pit/batch/commit", {
|
||||
projectId: workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
changes: {
|
||||
@@ -501,26 +494,26 @@ export const useCreateCommit = () => {
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, environment, secretPath }) => {
|
||||
onSuccess: (_, { projectId, environment, secretPath }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
|
||||
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
|
||||
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
|
||||
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
|
||||
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
|
||||
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -27,35 +27,35 @@ import {
|
||||
export const secretKeys = {
|
||||
// this is also used in secretSnapshot part
|
||||
getProjectSecret: ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
viewSecretValue
|
||||
}: TGetProjectSecretsKey) =>
|
||||
[{ workspaceId, environment, secretPath, viewSecretValue }, "secrets"] as const,
|
||||
[{ projectId, environment, secretPath, viewSecretValue }, "secrets"] as const,
|
||||
getSecretVersion: (secretId: string) => [{ secretId }, "secret-versions"] as const,
|
||||
getSecretAccessList: ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
secretKey
|
||||
}: TGetSecretAccessListDTO) =>
|
||||
["secret-access-list", { workspaceId, environment, secretPath, secretKey }] as const,
|
||||
["secret-access-list", { projectId, environment, secretPath, secretKey }] as const,
|
||||
getSecretReferenceTree: (dto: TGetSecretReferenceTreeDTO) => ["secret-reference-tree", dto]
|
||||
};
|
||||
|
||||
export const fetchProjectSecrets = async ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
includeImports,
|
||||
expandSecretReferences,
|
||||
viewSecretValue
|
||||
}: TGetProjectSecretsKey) => {
|
||||
const { data } = await apiRequest.get<SecretV3RawResponse>("/api/v3/secrets/raw", {
|
||||
const { data } = await apiRequest.get<SecretV3RawResponse>("/api/v4/secrets", {
|
||||
params: {
|
||||
environment,
|
||||
workspaceId,
|
||||
projectId,
|
||||
secretPath,
|
||||
viewSecretValue,
|
||||
expandSecretReferences,
|
||||
@@ -116,7 +116,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
|
||||
};
|
||||
|
||||
export const useGetProjectSecrets = ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
viewSecretValue,
|
||||
@@ -135,14 +135,14 @@ export const useGetProjectSecrets = ({
|
||||
useQuery({
|
||||
...options,
|
||||
// wait for all values to be available
|
||||
enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true),
|
||||
enabled: Boolean(projectId && environment) && (options?.enabled ?? true),
|
||||
queryKey: secretKeys.getProjectSecret({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath,
|
||||
viewSecretValue
|
||||
}),
|
||||
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath, viewSecretValue }),
|
||||
queryFn: () => fetchProjectSecrets({ projectId, environment, secretPath, viewSecretValue }),
|
||||
select: useCallback(
|
||||
(data: Awaited<ReturnType<typeof fetchProjectSecrets>>) => mergePersonalSecrets(data.secrets),
|
||||
[]
|
||||
@@ -150,7 +150,7 @@ export const useGetProjectSecrets = ({
|
||||
});
|
||||
|
||||
export const useGetProjectSecretsAllEnv = ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
envs,
|
||||
secretPath
|
||||
}: TGetProjectSecretsAllEnvDTO) => {
|
||||
@@ -159,11 +159,11 @@ export const useGetProjectSecretsAllEnv = ({
|
||||
const secrets = useQueries({
|
||||
queries: envs.map((environment) => ({
|
||||
queryKey: secretKeys.getProjectSecret({
|
||||
workspaceId,
|
||||
projectId,
|
||||
environment,
|
||||
secretPath
|
||||
}),
|
||||
enabled: Boolean(workspaceId && environment),
|
||||
enabled: Boolean(projectId && environment),
|
||||
onError: (error: unknown) => {
|
||||
if (axios.isAxiosError(error) && !isErrorHandled) {
|
||||
const { message, requestId } = error.response?.data as {
|
||||
@@ -187,7 +187,7 @@ export const useGetProjectSecretsAllEnv = ({
|
||||
setIsErrorHandled.on();
|
||||
}
|
||||
},
|
||||
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath }),
|
||||
queryFn: () => fetchProjectSecrets({ projectId, environment, secretPath }),
|
||||
staleTime: 60 * 1000,
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
select: useCallback(
|
||||
@@ -270,7 +270,7 @@ export const useGetSecretAccessList = (dto: TGetSecretAccessListDTO) =>
|
||||
users: SecretAccessListEntry[];
|
||||
}>(`/api/v1/secrets/${dto.secretKey}/access-list`, {
|
||||
params: {
|
||||
workspaceId: dto.workspaceId,
|
||||
projectId: dto.projectId,
|
||||
environment: dto.environment,
|
||||
secretPath: dto.secretPath
|
||||
}
|
||||
@@ -287,11 +287,11 @@ const fetchSecretReferenceTree = async ({
|
||||
environmentSlug
|
||||
}: TGetSecretReferenceTreeDTO) => {
|
||||
const { data } = await apiRequest.get<{ tree: TSecretReferenceTraceNode; value: string }>(
|
||||
`/api/v3/secrets/raw/${secretKey}/secret-reference-tree`,
|
||||
`/api/v4/secrets/${secretKey}/secret-reference-tree`,
|
||||
{
|
||||
params: {
|
||||
secretPath,
|
||||
workspaceId: projectId,
|
||||
projectId,
|
||||
environment: environmentSlug
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,30 +17,6 @@ export type SecretReminderRecipient = {
|
||||
};
|
||||
id: string;
|
||||
};
|
||||
export type EncryptedSecret = {
|
||||
id: string;
|
||||
version: number;
|
||||
workspace: string;
|
||||
type: SecretType;
|
||||
environment: string;
|
||||
secretKeyCiphertext: string;
|
||||
secretKeyIV: string;
|
||||
secretKeyTag: string;
|
||||
secretValueCiphertext: string;
|
||||
secretValueIV: string;
|
||||
secretValueTag: string;
|
||||
secretValueHidden: boolean;
|
||||
__v: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
skipMultilineEncoding?: boolean;
|
||||
secretCommentCiphertext: string;
|
||||
secretCommentIV: string;
|
||||
secretCommentTag: string;
|
||||
secretReminderRepeatDays?: number | null;
|
||||
secretReminderNote?: string | null;
|
||||
tags: WsTag[];
|
||||
};
|
||||
|
||||
// both personal and shared secret stitched together for dashboard
|
||||
export type SecretV3RawSanitized = {
|
||||
@@ -76,7 +52,7 @@ export type SecretV3RawSanitized = {
|
||||
export type SecretV3Raw = {
|
||||
id: string;
|
||||
_id: string;
|
||||
workspace: string;
|
||||
project: string;
|
||||
environment: string;
|
||||
version: number;
|
||||
type: string;
|
||||
@@ -113,7 +89,7 @@ export type SecretVersions = {
|
||||
id: string;
|
||||
secretId: string;
|
||||
version: number;
|
||||
workspace: string;
|
||||
project: string;
|
||||
type: SecretType;
|
||||
isDeleted: boolean;
|
||||
envId: string;
|
||||
@@ -136,7 +112,7 @@ export type SecretVersions = {
|
||||
|
||||
// dto
|
||||
export type TGetProjectSecretsKey = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath?: string;
|
||||
includeImports?: boolean;
|
||||
@@ -148,7 +124,7 @@ export type TGetProjectSecretsKey = {
|
||||
export type TGetProjectSecretsDTO = TGetProjectSecretsKey;
|
||||
|
||||
export type TGetProjectSecretsAllEnvDTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
envs: string[];
|
||||
folderId?: string;
|
||||
secretPath?: string;
|
||||
@@ -162,7 +138,7 @@ export type GetSecretVersionsDTO = {
|
||||
};
|
||||
|
||||
export type TGetSecretAccessListDTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
secretKey: string;
|
||||
@@ -174,14 +150,14 @@ export type TCreateSecretsV3DTO = {
|
||||
secretComment: string;
|
||||
skipMultilineEncoding?: boolean;
|
||||
secretPath: string;
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
type: SecretType;
|
||||
tagIds?: string[];
|
||||
};
|
||||
|
||||
export type TUpdateSecretsV3DTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
type: SecretType;
|
||||
@@ -198,7 +174,7 @@ export type TUpdateSecretsV3DTO = {
|
||||
};
|
||||
|
||||
export type TDeleteSecretsV3DTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
type: SecretType;
|
||||
secretPath: string;
|
||||
@@ -207,7 +183,7 @@ export type TDeleteSecretsV3DTO = {
|
||||
};
|
||||
|
||||
export type TCreateSecretBatchDTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
secrets: Array<{
|
||||
@@ -224,7 +200,7 @@ export type TCreateSecretBatchDTO = {
|
||||
};
|
||||
|
||||
export type TUpdateSecretBatchDTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
secrets: Array<{
|
||||
@@ -241,7 +217,7 @@ export type TUpdateSecretBatchDTO = {
|
||||
};
|
||||
|
||||
export type TDeleteSecretBatchDTO = {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
secrets: Array<{
|
||||
|
||||
Reference in New Issue
Block a user