@paulohenriquevn/m2js
Version:
Transform TypeScript/JavaScript code into LLM-friendly Markdown summaries + Smart Dead Code Detection + Graph-Deep Diff Analysis. Extract exported functions, classes, and JSDoc comments for better AI context with 60%+ token reduction. Intelligent dead cod
77 lines (76 loc) • 2.02 kB
TypeScript
/**
* Semantic Relationship Analyzer for M2JS
* Analyzes business entities, relationships, and workflows
*/
import { ParsedFile } from './types';
import { DependencyGraph } from './types';
export interface SemanticAnalysis {
entities: BusinessEntity[];
relationships: EntityRelationship[];
workflows: BusinessWorkflow[];
stateTransitions: StateTransition[];
invariants: BusinessInvariant[];
}
export interface BusinessEntity {
name: string;
type: 'aggregate' | 'entity' | 'value-object' | 'service';
properties: EntityProperty[];
operations: EntityOperation[];
description: string;
}
export interface EntityProperty {
name: string;
type: string;
required: boolean;
description?: string;
}
export interface EntityOperation {
name: string;
type: 'command' | 'query' | 'event';
parameters: string[];
returns: string;
sideEffects: boolean;
}
export interface EntityRelationship {
from: string;
to: string;
type: 'has-one' | 'has-many' | 'belongs-to' | 'uses' | 'depends-on' | 'creates' | 'validates';
cardinality: string;
description: string;
}
export interface BusinessWorkflow {
name: string;
description: string;
steps: WorkflowStep[];
triggers: string[];
outcomes: string[];
}
export interface WorkflowStep {
order: number;
action: string;
actor: string;
preconditions: string[];
postconditions: string[];
}
export interface StateTransition {
entity: string;
states: string[];
transitions: Transition[];
invariants: string[];
}
export interface Transition {
from: string;
to: string;
trigger: string;
conditions: string[];
}
export interface BusinessInvariant {
entity: string;
rule: string;
enforcement: string;
violations: string[];
}
/**
* Analyzes semantic relationships and business domain
*/
export declare function analyzeSemanticRelationships(parsedFiles: ParsedFile[], dependencyGraph: DependencyGraph): SemanticAnalysis;