UNPKG

@openinc/parse-server-opendash

Version:
115 lines (114 loc) 4.27 kB
import { Feature } from "../../config/helper/isFeatureEnabled"; /** * Configuration for an individual file within a documentation folder. */ export type FileConfig = { /** Sort order for this file (lower first). Defaults to 999 if not provided. */ order?: number; /** Icon identifier (e.g., fa:file). Defaults to fa:file */ icon?: string; /** Optional display title overriding file name */ title?: string; /** Location Pattern */ locationPattern?: string; /** locations */ locations?: string[]; /** Optional feature flag controlling visibility */ feature?: Feature; }; /** * Configuration for a documentation folder (from config.json) */ export type FolderConfig = { /** Display title for the folder (overrides folder name) */ title?: string; /** Sort order for this folder (lower numbers first) */ order?: number; /** Icon identifier for display */ icon?: string; /** Per-file configuration map (key = file name without extension) */ files?: Record<string, FileConfig>; /** Optional feature flag controlling the entire folder */ feature?: Feature; }; export type DocumentationFile = { /** Base name without extension */ name: string; /** Original filename including extension */ originalFilename?: string; path: string; sha: string; size?: number; extension: string; url: string; lastModified?: Date; lastModifiedBy?: string; lastCommitSha?: string; lastCommitMessage?: string; /** Raw textual content of the file (decoded UTF-8 for text-based files) */ content?: string; /** Timestamp from source control representing when the source was last modified (alias of lastModified for persistence clarity) */ fileLastModifiedAt?: Date; /** File-specific configuration (inherited from parent folder config.files entry) */ config?: FileConfig; }; export type DocumentationFolder = { name: string; path: string; files: DocumentationFile[]; subfolders: Map<string, DocumentationFolder>; /** Configuration from config.json file or default config (always present) */ config: FolderConfig; }; export type DocumentationStructure = { root: DocumentationFolder; allFiles: DocumentationFile[]; filesByExtension: Map<string, DocumentationFile[]>; }; export type ImportOptions = { branch?: string; repository: string; organization: string; token: string; fileFilter?: FileFilterOptions; /** Root path within the repository to start from (e.g., "docs" to start from docs folder) */ rootPath?: string; /** Default folder configuration to apply to folders without config.json */ defaultFolderConfig?: Partial<FolderConfig>; /** If provided, skip calling getBranch() and use this commit SHA directly (e.g., provided by external scheduler) */ preResolvedCommitSha?: string; }; export type FileFilterOptions = { /** Array of file extensions to include (without dots). If not provided, all files are included. */ includeExtensions?: string[]; /** Array of file extensions to exclude (without dots). Takes precedence over includeExtensions. */ excludeExtensions?: string[]; /** Path patterns to include (supports wildcards) */ includePaths?: string[]; /** Path patterns to exclude (supports wildcards) */ excludePaths?: string[]; }; export type ImportResult = { /** Documentation structure for this import. Undefined when skipped (no new commit). */ structure?: DocumentationStructure; metadata: { totalFiles: number; fileTypes: string[]; importedAt: Date; repository: string; branch: string; /** Latest commit SHA observed for the branch at import time */ commitSha: string; /** Previously imported commit SHA (if any) */ previousCommitSha?: string; /** Indicates the import was skipped because the commit SHA is unchanged */ skipped?: boolean; /** Reason for skipping (e.g., 'unchanged') */ skipReason?: string; /** Cleanup information when old documentation was removed */ cleanup?: { deletedDocuments: number; deletedCategories: number; }; }; };