@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:number
Analysis duration in ms
§timestamp:Date
Analysis timestamp
§version:string
Library version
§interface

AnalysisResult

Complete project analysis result.

Properties

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

BuildToolInfo

Build tool information.

Properties

§confidence:number
Detection confidence (0-100)
§configPath?:string
Config file path
§id:string
Tool identifier
§name:string
Human-readable name
§version?:string
Detected version
§interface

ConfigFileInfo

Detected configuration file.

Properties

§format:"json" | "yaml" | "js" | "ts" | "toml" | "env"
Config format
§name:string
File name
§path:string
File path
§tool?:string
Associated 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:string
Node identifier (same as path)
§path:string
File path
§interface

DependencySummary

Aggregated counts of dependencies by category.

Properties

§development:number
Dev dependency count
§optional:number
Optional dependency count
§peer:number
Peer dependency count
§production:number
Production dependency count
§total:number
Total count
§interface

EntryPointInfo

Discovered entry point.

Properties

§confidence:number
Detection confidence (0-100)
§path:string
File path
§type:"main" | "app" | "server" | "cli" | "test"
Entry point type
§interface

FrameworkInfo

Detected framework information.

Properties

§category:"frontend" | "backend" | "fullstack"
Category
§confidence:number
Detection confidence (0-100)
§id:string
Framework identifier
§metaFrameworks?:string[]
Meta-frameworks (e.g., Next.js for React)
§name:string
Human-readable name
§version?:string
Detected version
§interface

ProjectConfig

Project configuration (from package.json, project.json, etc.)

Properties

§description?:string
Description
§name:string
Project name
§projectType?:"application" | "library"
Project type (if NX project)
§sourceRoot?:string
Source root
§tags?:string[]
Tags
§version?:string
Version
§interface

TestingInfo

Testing framework information.

Properties

§confidence:number
Detection confidence (0-100)
§configPath?:string
Config file path
§id:string
Framework identifier
§name:string
Human-readable name
§type:"e2e" | "unit" | "integration"
Test type
§version?:string
Detected 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"