import ProjectFileSystem from '../commons/ProjectFileSystem'; /** * Conditions to match a reader */ export interface ProjectEntityMatchConditions { /** At least one file per pattern must exists to call the reader. The files will be used as input. */ requiredFilePatterns?: string[]; /** If any file exists that match the pattern, the reader will not be called */ mustNotExistFilePatterns?: string[]; /** Files matching the pattern will be used as input for the reader. */ filePatterns?: string[]; /** Files matching the pattern influence the reader, but will not provided as input. */ dependentPatterns?: string[]; /** Function to additionally match conditions. Returns true if valid, else false */ rule?: (context: { matchType: 'required' | 'mustNotExist'; fs: ProjectFileSystem; }) => Promise; /** File content matching the pattern */ watchContent?: any[]; } export type MatchedFiles = { [pattern: string]: string[]; }; export interface ProjectEntityReaderReadOptions { fs: ProjectFileSystem; matchedFiles: MatchedFiles; context?: any; } export default interface ProjectEntityReader { matchConditions: ProjectEntityMatchConditions; tags: string[]; /** * Read entity * * Match conditions are checked beforehand * * @param options * @returns Entity data or undefined if entity doesn't match * */ read(options: ProjectEntityReaderReadOptions): Promise; }