@hyperfrontend/project-scope/models

Models Module

The models module defines the core TypeScript types and interfaces used throughout the library. These types provide a consistent, well-documented structure for all analysis results and data exchanges.

Core Types

Project Classification

/**
 * Project type classification.
 */
type ProjectType = 'application' | 'library' | 'e2e' | 'tool' | 'plugin' | 'unknown'

/**
 * Workspace type (monorepo vs standalone).
 */
type WorkspaceType = 'nx' | 'turborepo' | 'lerna' | 'pnpm' | 'npm' | 'yarn' | 'standalone' | 'unknown'

Analysis Result

The main output type from analyzeProject():

interface AnalysisResult {
  /** Project name */
  name: string
  /** Project root path */
  root: string
  /** Project type classification */
  projectType: ProjectType
  /** Workspace type */
  workspaceType: WorkspaceType
  /** Detected frameworks */
  frameworks: FrameworkInfo[]
  /** Detected build tools */
  buildTools: BuildToolInfo[]
  /** Detected testing frameworks */
  testingFrameworks: TestingInfo[]
  /** Entry points */
  entryPoints: EntryPointInfo[]
  /** Configuration files found */
  configFiles: ConfigFileInfo[]
  /** Dependency summary */
  dependencies: DependencySummary
  /** Analysis metadata */
  metadata: AnalysisMetadata
}

Framework Information

interface FrameworkInfo {
  /** Framework identifier (e.g., 'react', 'angular') */
  id: string
  /** Human-readable name (e.g., 'React', 'Angular') */
  name: string
  /** Detected version */
  version?: string
  /** Detection confidence (0-100) */
  confidence: number
  /** Meta-frameworks (e.g., 'nextjs' for React) */
  metaFrameworks?: string[]
  /** Category */
  category: 'frontend' | 'backend' | 'fullstack'
}

Build Tool Information

interface BuildToolInfo {
  /** Tool identifier (e.g., 'webpack', 'vite') */
  id: string
  /** Human-readable name */
  name: string
  /** Detected version */
  version?: string
  /** Config file path */
  configPath?: string
  /** Detection confidence (0-100) */
  confidence: number
}

Testing Framework Information

interface TestingInfo {
  /** Framework identifier (e.g., 'jest', 'vitest') */
  id: string
  /** Human-readable name */
  name: string
  /** Detected version */
  version?: string
  /** Config file path */
  configPath?: string
  /** Test type */
  type: 'unit' | 'e2e' | 'integration'
  /** Detection confidence (0-100) */
  confidence: number
}

Entry Point Information

interface EntryPointInfo {
  /** File path relative to project root */
  path: string
  /** Entry point type */
  type: 'main' | 'app' | 'server' | 'cli' | 'test'
  /** Detection confidence (0-100) */
  confidence: number
}

Configuration File Information

interface ConfigFileInfo {
  /** File path relative to project root */
  path: string
  /** File name */
  name: string
  /** Config format */
  format: 'json' | 'yaml' | 'js' | 'ts' | 'toml' | 'env'
  /** Associated tool (e.g., 'typescript', 'eslint') */
  tool?: string
}

Dependency Summary

interface DependencySummary {
  /** Production dependency count */
  production: number
  /** Dev dependency count */
  development: number
  /** Peer dependency count */
  peer: number
  /** Optional dependency count */
  optional: number
  /** Total count */
  total: number
}

Dependency Graph

interface DependencyNode {
  /** Node identifier (file path) */
  id: string
  /** File path */
  path: string
  /** Files this node imports */
  dependencies: string[]
  /** Files that import this node */
  dependents: string[]
}

interface DependencyGraph {
  /** All nodes in the graph */
  nodes: Map<string, DependencyNode>
  /** Root files (not imported by anything) */
  roots: string[]
  /** Leaf files (don't import anything) */
  leaves: string[]
}

Analysis Metadata

interface AnalysisMetadata {
  /** When the analysis was performed */
  timestamp: Date
  /** Analysis duration in milliseconds */
  durationMs: number
  /** Library version used */
  version: string
}

Project Configuration

interface ProjectConfig {
  /** Project name */
  name: string
  /** Version */
  version?: string
  /** Description */
  description?: string
  /** Project type (for NX projects) */
  projectType?: 'application' | 'library'
  /** Source root directory */
  sourceRoot?: string
  /** Tags for filtering */
  tags?: string[]
}

Usage

Import types for use in your own code:

import type {
  AnalysisResult,
  ProjectType,
  WorkspaceType,
  FrameworkInfo,
  BuildToolInfo,
  TestingInfo,
  EntryPointInfo,
  ConfigFileInfo,
  DependencySummary,
  DependencyGraph,
} from '@hyperfrontend/project-scope'

function processAnalysis(result: AnalysisResult): void {
  if (result.projectType === 'library') {
    // Handle library-specific logic
  }
}

Design Principles

  1. Type safety: All interfaces are strictly typed
  2. Optional fields: Only truly optional fields are marked as such
  3. Consistent naming: IDs are lowercase, names are human-readable
  4. Confidence scores: All detections include confidence (0-100)
  5. Extensibility: Interfaces use string literals with sensible defaults

API Reference§

◈ Interfaces

§interface

AnalysisMetadata

Information about when and how the analysis was performed.
Properties
§durationMs:numberAnalysis duration in ms
§timestamp:DateAnalysis timestamp
§version:stringLibrary version
§interface

AnalysisResult

Complete project analysis result.
Properties
§buildTools:BuildToolInfo[]Detected build tools
§configFiles:ConfigFileInfo[]Configuration files found
§dependencies:DependencySummaryDependency summary
§entryPoints:EntryPointInfo[]Entry points
§frameworks:FrameworkInfo[]Detected frameworks
§metadata:AnalysisMetadataAnalysis metadata
§name:stringProject name
§projectType:ProjectTypeProject type classification
§root:stringProject root path
§testingFrameworks:TestingInfo[]Detected testing frameworks
§workspaceType:WorkspaceTypeWorkspace type
§interface

BuildToolInfo

Build tool information.
Properties
§confidence:numberDetection confidence (0-100)
§configPath?:stringConfig file path
§id:stringTool identifier
§name:stringHuman-readable name
§version?:stringDetected version
§interface

ConfigFileInfo

Detected configuration file.
Properties
§format:"json" | "yaml" | "js" | "ts" | "toml" | "env"Config format
§name:stringFile name
§path:stringFile path
§tool?:stringAssociated tool
§interface

DependencyGraph

Dependency graph structure.
Properties
§leaves:string[]Leaf files (don't import anything)
§nodes:Map<string, DependencyNode>Nodes in the graph
§roots:string[]Root files (not imported by anything)
§interface

DependencyNode

Dependency graph node.
Properties
§dependencies:string[]Files this node depends on
§dependents:string[]Files that depend on this node
§id:stringNode identifier (same as path)
§path:stringFile path
§interface

DependencySummary

Aggregated counts of dependencies by category.
Properties
§development:numberDev dependency count
§optional:numberOptional dependency count
§peer:numberPeer dependency count
§production:numberProduction dependency count
§total:numberTotal count
§interface

EntryPointInfo

Discovered entry point.
Properties
§confidence:numberDetection confidence (0-100)
§path:stringFile path
§type:"main" | "app" | "server" | "cli" | "test"Entry point type
§interface

FrameworkInfo

Detected framework information.
Properties
§category:"frontend" | "backend" | "fullstack"Category
§confidence:numberDetection confidence (0-100)
§id:stringFramework identifier
§metaFrameworks?:string[]Meta-frameworks (e.g., Next.js for React)
§name:stringHuman-readable name
§version?:stringDetected version
§interface

ProjectConfig

Project configuration (from package.json, project.json, etc.)
Properties
§description?:stringDescription
§name:stringProject name
§projectType?:"application" | "library"Project type (if NX project)
§sourceRoot?:stringSource root
§tags?:string[]Tags
§version?:stringVersion
§interface

TestingInfo

Testing framework information.
Properties
§confidence:numberDetection confidence (0-100)
§configPath?:stringConfig file path
§id:stringFramework identifier
§name:stringHuman-readable name
§type:"e2e" | "unit" | "integration"Test type
§version?:stringDetected version

◆ Types

§type

ProjectType

Project type classification.
type ProjectType = "application" | "library" | "e2e" | "tool" | "plugin" | "unknown"
§type

WorkspaceType

Workspace type (monorepo vs standalone).
type WorkspaceType = "nx" | "turborepo" | "lerna" | "pnpm" | "npm" | "yarn" | "standalone" | "unknown"