mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-17 02:47:35 +00:00
feat: secret reference graph for understanding how its pulled
This commit is contained in:
@@ -17,14 +17,17 @@ import {
|
||||
SecretVersions,
|
||||
TGetProjectSecretsAllEnvDTO,
|
||||
TGetProjectSecretsDTO,
|
||||
TGetProjectSecretsKey
|
||||
TGetProjectSecretsKey,
|
||||
TGetSecretReferenceTreeDTO,
|
||||
TSecretReferenceTraceNode
|
||||
} from "./types";
|
||||
|
||||
export const secretKeys = {
|
||||
// this is also used in secretSnapshot part
|
||||
getProjectSecret: ({ workspaceId, environment, secretPath }: TGetProjectSecretsKey) =>
|
||||
[{ workspaceId, environment, secretPath }, "secrets"] as const,
|
||||
getSecretVersion: (secretId: string) => [{ secretId }, "secret-versions"] as const
|
||||
getSecretVersion: (secretId: string) => [{ secretId }, "secret-versions"] as const,
|
||||
getSecretReferenceTree: (dto: TGetSecretReferenceTreeDTO) => ["secret-reference-tree", dto]
|
||||
};
|
||||
|
||||
export const fetchProjectSecrets = async ({
|
||||
@@ -227,3 +230,33 @@ export const useGetSecretVersion = (dto: GetSecretVersionsDTO) =>
|
||||
return data.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
||||
}, [])
|
||||
});
|
||||
|
||||
const fetchSecretReferenceTree = async ({
|
||||
secretPath,
|
||||
projectId,
|
||||
secretKey,
|
||||
environmentSlug
|
||||
}: TGetSecretReferenceTreeDTO) => {
|
||||
const { data } = await apiRequest.get<{ tree: TSecretReferenceTraceNode; value: string }>(
|
||||
`/api/v3/secrets/raw/${secretKey}/secret-reference-tree`,
|
||||
{
|
||||
params: {
|
||||
secretPath,
|
||||
workspaceId: projectId,
|
||||
environment: environmentSlug
|
||||
}
|
||||
}
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const useGetSecretReferenceTree = (dto: TGetSecretReferenceTreeDTO) =>
|
||||
useQuery({
|
||||
enabled:
|
||||
Boolean(dto.environmentSlug) &&
|
||||
Boolean(dto.secretPath) &&
|
||||
Boolean(dto.projectId) &&
|
||||
Boolean(dto.secretKey),
|
||||
queryKey: secretKeys.getSecretReferenceTree(dto),
|
||||
queryFn: () => fetchSecretReferenceTree(dto)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user