mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 08:27:36 +00:00
Fix: Restructured recursive path functions as suggested by Akhil
This commit is contained in:
@@ -74,13 +74,7 @@ type TGetPathsDTO = {
|
|||||||
interface FolderMap {
|
interface FolderMap {
|
||||||
[parentId: string]: TSecretFolders[];
|
[parentId: string]: TSecretFolders[];
|
||||||
}
|
}
|
||||||
|
const buildHierarchy = (folders: TSecretFolders[]): FolderMap => {
|
||||||
export const recursivelyGetSecretPaths = ({
|
|
||||||
folderDAL,
|
|
||||||
projectEnvDAL,
|
|
||||||
permissionService
|
|
||||||
}: TRecursivelyFetchSecretsFromFoldersArg) => {
|
|
||||||
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
|
||||||
|
|
||||||
@@ -93,13 +87,13 @@ export const recursivelyGetSecretPaths = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
};
|
};
|
||||||
|
|
||||||
const generatePaths = (
|
const generatePaths = (
|
||||||
map: FolderMap,
|
map: FolderMap,
|
||||||
parentId: string = "null",
|
parentId: string = "null",
|
||||||
basePath: string = ""
|
basePath: string = ""
|
||||||
): { path: string; folderId: string }[] => {
|
): { path: string; folderId: string }[] => {
|
||||||
const children = map[parentId || "null"] || [];
|
const children = map[parentId || "null"] || [];
|
||||||
let paths: { path: string; folderId: string }[] = [];
|
let paths: { path: string; folderId: string }[] = [];
|
||||||
|
|
||||||
@@ -127,9 +121,14 @@ 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 = {
|
||||||
|
|||||||
Reference in New Issue
Block a user