Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(frontend): migration API hooks for Doppler external migration

Igor Correa483bbf005b54
diff --git a/frontend/src/hooks/api/migration/mutations.tsx b/frontend/src/hooks/api/migration/mutations.tsx
index 00d3148efe..0bdba3471b 100644
--- a/frontend/src/hooks/api/migration/mutations.tsx
+++ b/frontend/src/hooks/api/migration/mutations.tsx
@@ -6,7 +6,13 @@ import { secretKeys } from "@app/hooks/api/secrets/queries";
import { projectKeys } from "../projects";
import { externalMigrationQueryKeys } from "./queries";
-import { TImportVaultSecretsDTO, TVaultExternalMigrationConfig, VaultImportStatus } from "./types";
+import {
+ TDopplerExternalMigrationConfig,
+ TImportDopplerSecretsDTO,
+ TImportVaultSecretsDTO,
+ TVaultExternalMigrationConfig,
+ VaultImportStatus
+} from "./types";
export const useImportEnvKey = () => {
const queryClient = useQueryClient();
@@ -163,3 +169,83 @@ export const useDeleteVaultExternalMigrationConfig = () => {
}
});
};
+
+export const useCreateDopplerExternalMigrationConfig = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<TDopplerExternalMigrationConfig, Error, { connectionId: string }>({
+ mutationFn: async ({ connectionId }) => {
+ const { data } = await apiRequest.post<{ config: TDopplerExternalMigrationConfig }>(
+ "/api/v3/external-migration/doppler/configs",
+ { connectionId }
+ );
+ return data.config;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({
+ queryKey: externalMigrationQueryKeys.dopplerConfigs()
+ });
+ }
+ });
+};
+
+export const useUpdateDopplerExternalMigrationConfig = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<
+ TDopplerExternalMigrationConfig,
+ Error,
+ { id: string; connectionId: string }
+ >({
+ mutationFn: async ({ id, connectionId }) => {
+ const { data } = await apiRequest.put<{ config: TDopplerExternalMigrationConfig }>(
+ `/api/v3/external-migration/doppler/configs/${id}`,
+ { connectionId }
+ );
+ return data.config;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({
+ queryKey: externalMigrationQueryKeys.dopplerConfigs()
+ });
+ }
+ });
+};
+
+export const useDeleteDopplerExternalMigrationConfig = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<TDopplerExternalMigrationConfig, Error, { id: string }>({
+ mutationFn: async ({ id }) => {
+ const { data } = await apiRequest.delete<{ config: TDopplerExternalMigrationConfig }>(
+ `/api/v3/external-migration/doppler/configs/${id}`
+ );
+ return data.config;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({
+ queryKey: externalMigrationQueryKeys.dopplerConfigs()
+ });
+ }
+ });
+};
+
+export const useImportDopplerSecrets = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<void, Error, TImportDopplerSecretsDTO>({
+ mutationFn: async (dto) => {
+ await apiRequest.post("/api/v3/external-migration/doppler/import-secrets", dto);
+ },
+ onSuccess: (_, { targetProjectId, targetEnvironment, targetSecretPath }) => {
+ queryClient.invalidateQueries({ queryKey: dashboardKeys.all() });
+ queryClient.invalidateQueries({
+ queryKey: secretKeys.getProjectSecret({
+ projectId: targetProjectId,
+ environment: targetEnvironment,
+ secretPath: targetSecretPath
+ })
+ });
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/migration/queries.tsx b/frontend/src/hooks/api/migration/queries.tsx
index 77ee0e3620..a4c5041c01 100644
--- a/frontend/src/hooks/api/migration/queries.tsx
+++ b/frontend/src/hooks/api/migration/queries.tsx
@@ -4,6 +4,9 @@ import { apiRequest } from "@app/config/request";
import {
ExternalMigrationProviders,
+ TDopplerEnvironment,
+ TDopplerExternalMigrationConfig,
+ TDopplerProject,
TVaultExternalMigrationConfig,
VaultDatabaseRole,
VaultKubernetesAuthRole,
@@ -49,6 +52,13 @@ export const externalMigrationQueryKeys = {
"vault-ldap-roles",
namespace,
mountPath
+ ],
+ dopplerConfigs: () => ["doppler-external-migration-configs"],
+ dopplerProjects: (configId?: string) => ["doppler-projects", configId],
+ dopplerEnvironments: (configId?: string, projectSlug?: string) => [
+ "doppler-environments",
+ configId,
+ projectSlug
]
};
@@ -267,3 +277,47 @@ export const useGetVaultLdapRoles = (enabled = true, namespace?: string, mountPa
enabled: enabled && !!namespace && !!mountPath
});
};
+
+export const useGetDopplerExternalMigrationConfigs = () => {
+ return useQuery({
+ queryKey: externalMigrationQueryKeys.dopplerConfigs(),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ configs: TDopplerExternalMigrationConfig[] }>(
+ "/api/v3/external-migration/doppler/configs"
+ );
+ return data.configs;
+ }
+ });
+};
+
+export const useGetDopplerProjects = (configId?: string) => {
+ return useQuery({
+ queryKey: externalMigrationQueryKeys.dopplerProjects(configId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ projects: TDopplerProject[] }>(
+ "/api/v3/external-migration/doppler/projects",
+ {
+ params: { configId }
+ }
+ );
+ return data.projects;
+ },
+ enabled: !!configId
+ });
+};
+
+export const useGetDopplerEnvironments = (configId?: string, projectSlug?: string) => {
+ return useQuery({
+ queryKey: externalMigrationQueryKeys.dopplerEnvironments(configId, projectSlug),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ environments: TDopplerEnvironment[] }>(
+ "/api/v3/external-migration/doppler/environments",
+ {
+ params: { configId, projectSlug }
+ }
+ );
+ return data.environments;
+ },
+ enabled: !!configId && !!projectSlug
+ });
+};
diff --git a/frontend/src/hooks/api/migration/types.ts b/frontend/src/hooks/api/migration/types.ts
index f9f4336ba2..31dd81fa4b 100644
--- a/frontend/src/hooks/api/migration/types.ts
+++ b/frontend/src/hooks/api/migration/types.ts
@@ -1,8 +1,41 @@
export enum ExternalMigrationProviders {
Vault = "vault",
- EnvKey = "env-key"
+ EnvKey = "env-key",
+ Doppler = "doppler"
}
+export type TDopplerExternalMigrationConfig = {
+ id: string;
+ orgId: string;
+ connectionId: string | null;
+ provider: string;
+ createdAt: string;
+ updatedAt: string;
+};
+
+export type TDopplerProject = {
+ id: string;
+ slug: string;
+ name: string;
+ description: string;
+};
+
+export type TDopplerEnvironment = {
+ id: string;
+ slug: string;
+ name: string;
+ project: string;
+};
+
+export type TImportDopplerSecretsDTO = {
+ configId: string;
+ dopplerProject: string;
+ dopplerEnvironment: string;
+ targetProjectId: string;
+ targetEnvironment: string;
+ targetSecretPath: string;
+};
+
export enum VaultImportStatus {
Imported = "imported",
ApprovalRequired = "approval-required"