Begin marking endpoints for deprecation, clean unused frontend code

This commit is contained in:
Tuan Dang
2023-08-09 16:45:52 +07:00
parent 11833ccf0f
commit 2a1665a2c3
37 changed files with 135 additions and 1929 deletions
+23 -2
View File
@@ -11,13 +11,13 @@ import { apiRequest } from "@app/config/request";
import { secretSnapshotKeys } from "../secretSnapshots/queries";
import {
BatchSecretDTO,
CreateSecretDTO,
DecryptedSecret,
EncryptedSecret,
EncryptedSecretVersion,
GetProjectSecretsDTO,
GetSecretVersionsDTO,
TGetProjectSecretsAllEnvDTO
} from "./types";
TGetProjectSecretsAllEnvDTO} from "./types";
export const secretKeys = {
// this is also used in secretSnapshot part
@@ -324,3 +324,24 @@ export const useBatchSecretsOp = () => {
}
});
};
export const createSecret = async (dto: CreateSecretDTO) => {
const { data } = await apiRequest.post(`/api/v3/secrets/${dto.secretKey}`, dto);
return data;
}
export const useCreateSecret = () => {
const queryClient = useQueryClient();
return useMutation<{}, {}, CreateSecretDTO>({
mutationFn: async (dto) => {
const data = createSecret(dto);
return data;
},
onSuccess: (_, dto) => {
queryClient.invalidateQueries(
secretKeys.getProjectSecret(dto.workspaceId, dto.environment)
);
}
});
};
+19
View File
@@ -147,3 +147,22 @@ export type TDeleteSecretsV3DTO = {
secretPath: string;
secretName: string;
};
// --- v3
export type CreateSecretDTO = {
workspaceId: string;
environment: string;
type: "shared" | "personal";
secretKey: string;
secretKeyCiphertext: string;
secretKeyIV: string;
secretKeyTag: string;
secretValueCiphertext: string;
secretValueIV: string;
secretValueTag: string;
secretCommentCiphertext: string;
secretCommentIV: string;
secretCommentTag: string;
secretPath: string;
}