code-relation-analyzer
Version:
A TypeScript project dependency analysis tool that generates function-level dependency graphs
263 lines • 6.7 kB
TypeScript
/**
* 项目相关类型定义
*/
export interface ProjectInfo {
/** 项目唯一标识符 */
id: string;
/** 项目名称 */
name: string;
/** 项目路径 */
path: string;
/** 项目版本 */
version?: string;
/** 项目描述 */
description?: string;
/** 分析时间 */
analyzedAt: Date;
/** 生成时间 */
generatedAt?: Date;
/** 总文件数 */
totalFiles: number;
/** 总函数数 */
totalFunctions: number;
/** 总类数 */
totalClasses: number;
/** 复杂度评分 */
complexityScore: number;
/** TypeScript配置 */
tsConfig?: TSConfig;
/** package.json 信息 */
packageJson?: {
name?: string;
version?: string;
description?: string;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
};
/** 依赖信息 */
dependencies?: Record<string, string>;
/** 开发依赖信息 */
devDependencies?: Record<string, string>;
/** 入口点 */
entryPoints?: string[];
}
export interface TSConfig {
/** 编译选项 */
compilerOptions: {
target?: string;
module?: string;
lib?: string[];
outDir?: string;
rootDir?: string;
strict?: boolean;
baseUrl?: string;
paths?: Record<string, string[]>;
};
/** 包含的文件模式 */
include?: string[];
/** 排除的文件模式 */
exclude?: string[];
/** 文件列表 */
files?: string[];
/** 继承配置 */
extends?: string;
}
export interface FileInfo {
/** 文件唯一标识符 */
id: string;
/** 项目ID */
projectId: string;
/** 文件路径 */
path: string;
/** 文件名 */
name: string;
/** 文件扩展名 */
extension: string;
/** 行数 */
lineCount: number;
/** 文件大小(字节) */
fileSize: number;
/** 最后修改时间 */
lastModified: Date;
/** 文件类型 */
fileType: FileType;
/** 是否为入口文件 */
isEntryPoint: boolean;
/** 导出的符号 */
exports: ExportInfo[];
/** 导入的符号 */
imports: ImportInfo[];
/** 函数列表 */
functions: FunctionInfo[];
/** 类列表 */
classes: ClassInfo[];
/** 接口列表 */
interfaces: ClassInfo[];
/** 注释列表 */
comments?: any[];
/** 文件行数 */
lines?: number;
/** 文件大小 */
size?: number;
/** 代码行数 */
linesOfCode?: number;
/** 文件内容 */
content?: string;
}
export type FileType = 'component' | 'service' | 'utility' | 'type' | 'config' | 'test' | 'unknown';
export interface ExportInfo {
/** 导出名称 */
name: string;
/** 导出类型 */
type: ExportType;
/** 是否为默认导出 */
isDefault: boolean;
/** 行号 */
startLine: number;
/** 注释 */
comment?: string;
/** 源文件路径 */
source?: string | undefined;
}
export type ExportType = 'function' | 'class' | 'interface' | 'type' | 'variable' | 'constant' | 'named' | 'namespace' | 'default';
export interface ImportInfo {
/** 导入的模块路径 */
moduleSpecifier: string;
/** 导入的符号 */
importedSymbols: string[];
/** 导入类型 */
importType: ImportType;
/** 是否仅类型导入 */
isTypeOnly: boolean;
/** 行号 */
startLine: number;
/** 行号(兼容性) */
lineNumber: number;
}
export type ImportType = 'default' | 'named' | 'namespace' | 'dynamic';
export interface FunctionInfo {
/** 函数唯一标识符 */
id: string;
/** 文件ID */
fileId: string;
/** 函数名 */
name: string;
/** 函数签名 */
signature: string;
/** 返回类型 */
returnType: string;
/** 参数列表 */
parameters: ParameterInfo[];
/** 复杂度 */
complexity: number;
/** 行数 */
lineCount: number;
/** 开始行号 */
startLine: number;
/** 结束行号 */
endLine: number;
/** 是否导出 */
isExported: boolean;
/** 是否异步 */
isAsync: boolean;
/** 可见性 */
visibility: Visibility;
/** 注释 */
comment?: string;
/** 装饰器 */
decorators?: string[];
/** 访问的属性列表 */
accessedProperties?: string[];
}
export interface ParameterInfo {
/** 参数名称 */
name: string;
/** 参数类型 */
type: string;
/** 是否可选 */
isOptional: boolean;
/** 默认值 */
defaultValue?: string;
/** 是否为剩余参数 */
isRest: boolean;
}
export type Visibility = 'public' | 'private' | 'protected';
export interface ClassInfo {
/** 类唯一标识符 */
id: string;
/** 文件ID */
fileId: string;
/** 类名 */
name: string;
/** 类类型 */
type: ClassType;
/** 是否抽象类 */
isAbstract: boolean;
/** 是否导出 */
isExported: boolean;
/** 开始行号 */
startLine: number;
/** 结束行号 */
endLine: number;
/** 属性列表 */
properties: PropertyInfo[];
/** 方法列表 */
methods: FunctionInfo[];
/** 构造函数 */
constructor?: FunctionInfo | undefined;
/** 注释 */
comment?: string;
/** 装饰器 */
decorators?: string[];
/** 类型参数 */
typeParameters?: string[];
/** 实现的接口 */
implements?: string[];
/** 继承的父类 */
extends?: string | undefined;
}
export type ClassType = 'class' | 'interface' | 'enum' | 'type';
export interface PropertyInfo {
/** 属性名称 */
name: string;
/** 属性类型 */
type: string;
/** 可见性 */
visibility: Visibility;
/** 是否只读 */
isReadonly: boolean;
/** 是否静态 */
isStatic: boolean;
/** 是否可选 */
isOptional: boolean;
/** 默认值 */
defaultValue?: string;
/** 行号 */
startLine: number;
/** 注释 */
comment?: string;
/** 装饰器 */
decorators?: string[];
}
export interface DependencyInfo {
/** 依赖唯一标识符 */
id: string;
/** 源文件ID */
sourceFileId: string;
/** 目标文件ID */
targetFileId: string;
/** 依赖类型 */
type: DependencyType;
/** 依赖强度 */
strength: number;
/** 是否为循环依赖 */
isCircular: boolean;
/** 依赖路径 */
path: string[];
/** 导入的符号 */
importedSymbols: string[];
/** 行号 */
lineNumber: number;
}
export type DependencyType = 'import' | 'export' | 'inheritance' | 'composition' | 'aggregation' | 'usage';
//# sourceMappingURL=project.d.ts.map