import { Brackets, WhereExpressionBuilder } from 'typeorm'; import type { SessionContext } from './SessionContext'; import { DirectoryCacheDTO, SubDirectoryDTO } from '../../common/entities/DirectoryDTO'; import { DirectorySearch } from '../../common/entities/SearchQueryDTO'; export declare enum DirectoryAccessTypes { none = 0,// not available, behaves as if it would not exist parent = 1,// can be opened to navigate to available directories, but its own content is hidden available = 2 } /** * Directory filter prebuilt for the two directory aliases used in the queries */ export interface DirectoryFilter { directory: Brackets; directories: Brackets; } /** * Decides which directories a session can open, based on the directory allow and block lists. * It lives in SessionContext.directoryAccess. * - A blocked directory is never available. * - A directory matching all allow lists is available. * - Users can open the parents of the available directories (their content is hidden). * These parents are found from the path for anchored searches (exact path, 'path/*'), otherwise from the DB. * - Sharing users can't open parents. * - Sharing without directory query: only directories with visible photos are available, * directories with visible photos below them are parents. */ export declare class DirectoryAccess { allowLists?: DirectorySearch[][]; blockList?: DirectorySearch[]; byPhotos?: boolean; allowQuery?: DirectoryFilter; notBlockedQuery?: DirectoryFilter; private readonly context; constructor(context: SessionContext, init?: Partial>); get isSharing(): boolean; isBlocked(dirPath: string): boolean; /** * True if the directory matches all allow lists (does not check the block list) */ isAllowed(dirPath: string): boolean; /** * Media and metafiles of a directory are only shown if it is available. */ isAvailable(dirPath: string): Promise; getAccess(dirPath: string): Promise; /** * Which parents (root is the first) the session can open. * The directory itself is accessible, so all its parents lead to an available directory. */ getAvailableParents(dirPath: string): boolean[]; /** * Directories in search results and autocomplete need to be available (not just parents) */ isListedInSearch(cache: DirectoryCacheDTO | undefined): boolean; /** * Applies the directory allow/block list on a directory query. * Parents are not added, those need to be filtered by the caller (see isListedInSearch). */ filterDirectoryQuery(qb: WhereExpressionBuilder, alias: keyof DirectoryFilter): void; /** * Filters the subdirectories of a listed directory. The caches of the subdirectories need to be filled. */ filterSubDirectories(parent: { path: string; name: string; }, subDirs: T[]): Promise; private isAnchoredParent; /** * Parents of like, negated and non-trailing glob searches can only be found from the DB */ private needsDBForParents; private getAccessByPhotos; /** * Returns the available (allowed and not blocked) directories below the given directory */ private getAvailableDirectoriesBelow; }