mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
Implement DDD aggregate boundary validation to detect and prevent direct entity references across aggregate boundaries. Features: - Detect direct entity imports between aggregates - Allow only ID or Value Object references - Support multiple folder structures (domain/aggregates/*, domain/*, domain/entities/*) - Filter allowed imports (value-objects, events, repositories, services) - Critical severity level for violations - 41 comprehensive tests with 92.55% coverage - CLI output with detailed suggestions - Examples of good and bad patterns Breaking changes: None Backwards compatible: Yes
101 lines
2.4 KiB
TypeScript
101 lines
2.4 KiB
TypeScript
export const APP_CONSTANTS = {
|
|
DEFAULT_TIMEOUT: 5000,
|
|
MAX_RETRIES: 3,
|
|
VERSION: "0.0.1",
|
|
} as const
|
|
|
|
export const ERROR_MESSAGES = {
|
|
VALIDATION_FAILED: "Validation failed",
|
|
NOT_FOUND: "Resource not found",
|
|
UNAUTHORIZED: "Unauthorized access",
|
|
INTERNAL_ERROR: "Internal server error",
|
|
FAILED_TO_ANALYZE: "Failed to analyze project",
|
|
FAILED_TO_SCAN_DIR: "Failed to scan directory",
|
|
FAILED_TO_READ_FILE: "Failed to read file",
|
|
ENTITY_NOT_FOUND: "Entity with id {id} not found",
|
|
} as const
|
|
|
|
/**
|
|
* Error codes
|
|
*/
|
|
export const ERROR_CODES = {
|
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
NOT_FOUND: "NOT_FOUND",
|
|
UNAUTHORIZED: "UNAUTHORIZED",
|
|
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
} as const
|
|
|
|
/**
|
|
* File extension constants
|
|
*/
|
|
export const FILE_EXTENSIONS = {
|
|
TYPESCRIPT: ".ts",
|
|
TYPESCRIPT_JSX: ".tsx",
|
|
JAVASCRIPT: ".js",
|
|
JAVASCRIPT_JSX: ".jsx",
|
|
} as const
|
|
|
|
/**
|
|
* TypeScript primitive type names
|
|
*/
|
|
export const TYPE_NAMES = {
|
|
STRING: "string",
|
|
NUMBER: "number",
|
|
BOOLEAN: "boolean",
|
|
OBJECT: "object",
|
|
} as const
|
|
|
|
/**
|
|
* Common regex patterns
|
|
*/
|
|
export const REGEX_PATTERNS = {
|
|
IMPORT_STATEMENT: /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g,
|
|
EXPORT_STATEMENT: /export\s+(?:class|function|const|let|var)\s+(\w+)/g,
|
|
} as const
|
|
|
|
/**
|
|
* Placeholders for string templates
|
|
*/
|
|
export const PLACEHOLDERS = {
|
|
ID: "{id}",
|
|
} as const
|
|
|
|
/**
|
|
* Violation severity levels
|
|
*/
|
|
export const SEVERITY_LEVELS = {
|
|
CRITICAL: "critical",
|
|
HIGH: "high",
|
|
MEDIUM: "medium",
|
|
LOW: "low",
|
|
} as const
|
|
|
|
export type SeverityLevel = (typeof SEVERITY_LEVELS)[keyof typeof SEVERITY_LEVELS]
|
|
|
|
/**
|
|
* Severity order for sorting (lower number = more critical)
|
|
*/
|
|
export const SEVERITY_ORDER: Record<SeverityLevel, number> = {
|
|
[SEVERITY_LEVELS.CRITICAL]: 0,
|
|
[SEVERITY_LEVELS.HIGH]: 1,
|
|
[SEVERITY_LEVELS.MEDIUM]: 2,
|
|
[SEVERITY_LEVELS.LOW]: 3,
|
|
} as const
|
|
|
|
/**
|
|
* Violation type to severity mapping
|
|
*/
|
|
export const VIOLATION_SEVERITY_MAP = {
|
|
CIRCULAR_DEPENDENCY: SEVERITY_LEVELS.CRITICAL,
|
|
REPOSITORY_PATTERN: SEVERITY_LEVELS.CRITICAL,
|
|
AGGREGATE_BOUNDARY: SEVERITY_LEVELS.CRITICAL,
|
|
DEPENDENCY_DIRECTION: SEVERITY_LEVELS.HIGH,
|
|
FRAMEWORK_LEAK: SEVERITY_LEVELS.HIGH,
|
|
ENTITY_EXPOSURE: SEVERITY_LEVELS.HIGH,
|
|
NAMING_CONVENTION: SEVERITY_LEVELS.MEDIUM,
|
|
ARCHITECTURE: SEVERITY_LEVELS.MEDIUM,
|
|
HARDCODE: SEVERITY_LEVELS.LOW,
|
|
} as const
|
|
|
|
export * from "./rules"
|