Fix: Restructured recursive path functions as suggested by Akhil

This commit is contained in:
Daniel Hougaard
2024-04-01 09:58:13 -07:00
parent b9482966cf
commit da2dcb347a
+8 -7
View File
@@ -74,12 +74,6 @@ type TGetPathsDTO = {
interface FolderMap { interface FolderMap {
[parentId: string]: TSecretFolders[]; [parentId: string]: TSecretFolders[];
} }
export const recursivelyGetSecretPaths = ({
folderDAL,
projectEnvDAL,
permissionService
}: TRecursivelyFetchSecretsFromFoldersArg) => {
const buildHierarchy = (folders: TSecretFolders[]): FolderMap => { const buildHierarchy = (folders: TSecretFolders[]): FolderMap => {
const map: FolderMap = {}; const map: FolderMap = {};
map.null = []; // Initialize mapping for root directory map.null = []; // Initialize mapping for root directory
@@ -129,7 +123,12 @@ export const recursivelyGetSecretPaths = ({
return paths; return paths;
}; };
return async ({ projectId, environment, currentPath, auth }: TGetPathsDTO) => { export const recursivelyGetSecretPaths = ({
folderDAL,
projectEnvDAL,
permissionService
}: TRecursivelyFetchSecretsFromFoldersArg) => {
const getPaths = async ({ projectId, environment, currentPath, auth }: TGetPathsDTO) => {
const env = await projectEnvDAL.findOne({ const env = await projectEnvDAL.findOne({
projectId, projectId,
slug: environment slug: environment
@@ -175,6 +174,8 @@ export const recursivelyGetSecretPaths = ({
return allowedPaths; return allowedPaths;
}; };
return getPaths;
}; };
type TInterpolateSecretArg = { type TInterpolateSecretArg = {