/** * Type definitions for the documentation generator */ interface DocGeneratorConfig { outputDir: string; site: SiteConfig; repositories: RepositoryConfig[]; analysis: AnalysisConfig; diagrams: DiagramConfig; watch: WatchConfig; integrations: IntegrationsConfig; } interface SiteConfig { title: string; description: string; baseUrl: string; } interface RepositoryConfig { name: string; displayName: string; description: string; path: string; remote?: string; branch: string; type: 'nextjs' | 'rails' | 'generic'; analyzers: AnalyzerType[]; settings: Record; } type AnalyzerType = 'pages' | 'graphql' | 'components' | 'dataflow' | 'rest-api' | 'api-endpoints' | 'graphql-schema' | 'models' | 'controllers' | 'routes' | 'grpc'; interface AnalysisConfig { include: string[]; exclude: string[]; maxDepth: number; } interface DiagramConfig { enabled: boolean; types: DiagramType[]; theme: string; } type DiagramType = 'flowchart' | 'sequence' | 'er' | 'class'; interface WatchConfig { enabled: boolean; debounce: number; } interface IntegrationsConfig { github: { enabled: boolean; organization: string; }; slack: { enabled: boolean; webhook?: string; }; } interface AnalysisResult { repository: string; timestamp: string; version: string; commitHash: string; /** Coverage / observability metrics to prevent silent omissions */ coverage?: CoverageMetrics; pages: PageInfo[]; graphqlOperations: GraphQLOperation[]; apiCalls: APICall[]; components: ComponentInfo[]; dataFlows: DataFlow[]; apiEndpoints: APIEndpoint[]; models: ModelInfo[]; crossRepoLinks: CrossRepoLink[]; } interface CoverageMetrics { /** Number of TS/TSX/JS/JSX files scanned by analyzers (best-effort) */ tsFilesScanned: number; /** Number of source files that failed to parse (SWC/TS parser failures) */ tsParseFailures: number; /** Number of GraphQL parse failures (graphql parse errors) */ graphqlParseFailures: number; /** Number of codegen files detected (best-effort) */ codegenFilesDetected: number; /** Number of codegen files successfully parsed by AST */ codegenFilesParsed: number; /** Number of Document exports extracted from codegen outputs */ codegenExportsFound: number; } /** * Frontend API call information */ interface APICall { /** Unique identifier */ id: string; /** HTTP method (GET, POST, PUT, DELETE, etc.) */ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'unknown'; /** URL or endpoint path */ url: string; /** Type of API call (fetch, axios, useSWR, etc.) */ callType: 'fetch' | 'axios' | 'useSWR' | 'useQuery' | 'custom'; /** File path where the call is made */ filePath: string; /** Line number in the file */ line: number; /** Component or function name containing the call */ containingFunction: string; /** Pages or components using this API call */ usedIn: string[]; /** Request body type if available */ requestType?: string; /** Response type if available */ responseType?: string; /** Whether authentication is required */ requiresAuth: boolean; /** Additional options or headers */ options?: Record; /** API category (e.g., 'HubSpot', 'AWS S3', 'Internal API') */ category?: string; } interface PageInfo { path: string; filePath: string; component: string; params: string[]; layout?: string; authentication: AuthRequirement; permissions: string[]; dataFetching: DataFetchingInfo[]; navigation: NavigationInfo; linkedPages: string[]; /** Multi-step flow information (wizard, onboarding, etc.) */ steps?: StepInfo[]; } interface StepInfo { /** Step number or identifier */ id: number | string; /** Step name/label if available */ name?: string; /** Component or content rendered in this step */ component?: string; /** Condition to show this step */ condition?: string; } interface AuthRequirement { required: boolean; roles?: string[]; condition?: string; } interface DataFetchingInfo { type: 'useQuery' | 'useMutation' | 'useLazyQuery' | 'getServerSideProps' | 'getStaticProps' | 'component' | 'useSubscription'; operationName: string; variables?: string[]; source?: string; /** * Confidence for the mapping between page <-> hook <-> operation. * - 'certain': direct/close evidence * - 'likely': reachable but indirect evidence * - 'unknown': reachable via widely-shared/common modules (UI may display this as "Common" or omit it) */ confidence?: 'certain' | 'likely' | 'unknown'; /** * Evidence for why this operation is linked. * This is primarily for debugging missing/incorrect links. */ evidence?: Array<{ kind: 'import-edge' | 'operation-reference'; file: string; line?: number; detail?: string; }>; } interface NavigationInfo { visible: boolean; currentNavItem: string | null; mini?: boolean; mainPageStyle?: Record; } interface GraphQLOperation { name: string; type: 'query' | 'mutation' | 'subscription' | 'fragment'; filePath: string; /** 1-based line number where the operation starts (best-effort) */ line?: number; /** 1-based column number where the operation starts (best-effort) */ column?: number; usedIn: string[]; variables: VariableInfo[]; returnType: string; fragments: string[]; fields: GraphQLField[]; /** Variable names that reference this operation (e.g., GET_USER_QUERY, GetUserDocument) */ variableNames?: string[]; } interface GraphQLField { name: string; type?: string; fields?: GraphQLField[]; } interface VariableInfo { name: string; type: string; required: boolean; } interface ComponentInfo { name: string; filePath: string; type: 'page' | 'container' | 'presentational' | 'layout' | 'hook'; props: PropInfo[]; dependencies: string[]; dependents: string[]; hooks: string[]; stateManagement: string[]; /** * Import information with resolved paths * Used for accurate GraphQL operation mapping */ imports?: ImportInfo[]; } interface ImportInfo { /** Imported name (e.g., "Query", "useUserHook") */ name: string; /** Import path (e.g., "../../features/profile/NewProfilePage") */ path: string; } interface PropInfo { name: string; type: string; required: boolean; defaultValue?: string; } interface DataFlow { id: string; name: string; description: string; source: DataFlowNode; target: DataFlowNode; via: DataFlowNode[]; operations: string[]; } interface DataFlowNode { type: 'component' | 'hook' | 'context' | 'api' | 'cache' | 'store'; name: string; repository?: string; } interface APIEndpoint { method: string; path: string; controller: string; action: string; authentication: boolean; permissions: string[]; parameters: ParameterInfo[]; responses: ResponseInfo[]; } interface ParameterInfo { name: string; type: string; location: 'path' | 'query' | 'body' | 'header'; required: boolean; } interface ResponseInfo { status: number; description: string; schema?: string; } interface ModelInfo { name: string; tableName: string; filePath: string; attributes: AttributeInfo[]; associations: AssociationInfo[]; validations: string[]; scopes: string[]; } interface AttributeInfo { name: string; type: string; nullable: boolean; default?: string; } interface AssociationInfo { type: 'belongs_to' | 'has_one' | 'has_many' | 'has_and_belongs_to_many'; name: string; model: string; foreignKey?: string; } interface CrossRepoLink { sourceRepo: string; sourcePath: string; targetRepo: string; targetPath: string; linkType: 'api-call' | 'shared-type' | 'graphql-operation' | 'navigation'; description: string; } interface MermaidDiagram { type: DiagramType; title: string; content: string; relatedFiles: string[]; } interface DocumentationReport { generatedAt: string; repositories: RepositoryReport[]; crossRepoAnalysis: CrossRepoAnalysis; diagrams: MermaidDiagram[]; } interface RepositoryReport { name: string; displayName: string; version: string; commitHash: string; analysis: AnalysisResult; summary: RepositorySummary; } interface RepositorySummary { totalPages: number; totalComponents: number; totalGraphQLOperations: number; totalDataFlows: number; authRequiredPages: number; publicPages: number; } interface CrossRepoAnalysis { sharedTypes: string[]; apiConnections: APIConnection[]; navigationFlows: NavigationFlow[]; dataFlowAcrossRepos: DataFlow[]; } interface APIConnection { frontend: string; backend: string; endpoint: string; operations: string[]; } interface NavigationFlow { from: { repo: string; page: string; }; to: { repo: string; page: string; }; trigger: string; } export type { APICall, APIConnection, APIEndpoint, AnalysisConfig, AnalysisResult, AnalyzerType, AssociationInfo, AttributeInfo, AuthRequirement, ComponentInfo, CoverageMetrics, CrossRepoAnalysis, CrossRepoLink, DataFetchingInfo, DataFlow, DataFlowNode, DiagramConfig, DiagramType, DocGeneratorConfig, DocumentationReport, GraphQLField, GraphQLOperation, ImportInfo, IntegrationsConfig, MermaidDiagram, ModelInfo, NavigationFlow, NavigationInfo, PageInfo, ParameterInfo, PropInfo, RepositoryConfig, RepositoryReport, RepositorySummary, ResponseInfo, SiteConfig, StepInfo, VariableInfo, WatchConfig };