UNPKG

@swoft/ddd

Version:

Domain-Driven Design (DDD) strategic and tactical design tools for domain modeling and bounded context management.

1,499 lines (1,483 loc) 148 kB
import { Entity, EntityId, BaseCommand, ICommand, ICommandHandler, BaseQuery, IQueryHandler, IEventBus, IPaginatedResult, DomainRulesContract, NamingRule, IntegrationRule, ArchitecturalRule, DomainCapability, DomainEventMetadata } from '@swoft/core'; export { DomainEvent, Entity, EntityId } from '@swoft/core'; import { z } from 'zod'; import { Request, Response, RequestHandler } from 'express'; import { ContainerModule } from 'inversify'; import { Document, Collection } from 'mongodb'; export { AggregateQueryCriteria, BoundedContextQueryCriteria, DomainQueryCriteria } from './integration/contracts/DomainQueryCriteria.js'; export { AggregateSummary, BoundedContextSummary, DDDQueryResult, DDDStatistics, DomainSummary } from './integration/contracts/DDDSummaryModels.js'; export { DDD_PUBLISHED_LANGUAGE_VERSION } from './integration/contracts/index.js'; /** * DDD Domain Dependency Injection Symbols * * Centralized symbols for dependency injection to avoid circular dependencies. * Extracted from DDDContainerModule to break circular import chains. */ declare const DDD_SYMBOLS: { readonly DomainApplicationService: symbol; readonly BoundedContextApplicationService: symbol; readonly AggregateApplicationService: symbol; readonly ProjectApplicationService: symbol; readonly PackageMappingApplicationService: symbol; readonly DomainCQRSQueryService: symbol; readonly BoundedContextQueryService: symbol; readonly AggregateQueryService: symbol; readonly ProjectQueryService: symbol; readonly DomainCommandService: symbol; readonly BoundedContextCommandService: symbol; readonly AggregateCommandService: symbol; readonly ProjectCommandService: symbol; readonly IDomainRepository: symbol; readonly IBoundedContextRepository: symbol; readonly IAggregateRepository: symbol; readonly IProjectRepository: symbol; readonly IPackageMappingRepository: symbol; readonly CreateDomainHandler: symbol; readonly UpdateDomainHandler: symbol; readonly GetDomainHandler: symbol; readonly ListDomainsHandler: symbol; readonly CreateBoundedContextHandler: symbol; readonly UpdateBoundedContextHandler: symbol; readonly GetBoundedContextHandler: symbol; readonly ListBoundedContextsHandler: symbol; readonly CreateAggregateHandler: symbol; readonly UpdateAggregateHandler: symbol; readonly GetAggregateHandler: symbol; readonly CreateProjectHandler: symbol; readonly UpdateProjectHandler: symbol; readonly GetProjectHandler: symbol; readonly ListProjectsHandler: symbol; readonly IEventBus: symbol; readonly ICommandBus: symbol; readonly IQueryBus: symbol; readonly IDomainAnalysisService: symbol; readonly IBoundedContextAnalysisService: symbol; readonly AIAnalysisService: symbol; readonly PersonLookupPort: symbol; readonly DomainIdFactory: symbol; readonly BoundedContextIdFactory: symbol; readonly AggregateIdFactory: symbol; readonly DomainController: symbol; readonly BoundedContextController: symbol; readonly AggregateController: symbol; readonly ProjectController: symbol; readonly PackageMappingController: symbol; readonly DatabasePort: symbol; }; /** * Aggregate Tactical Domain Model * * Rich domain model for DDD Aggregates with business invariants, * domain events, and entity relationships. Bridges strategic and * tactical modeling by connecting to bounded contexts. */ interface AggregateEntity { id: string; name: string; description?: string; properties: AggregateProperty[]; methods: AggregateMethod[]; } interface ValueObjectDefinition { id: string; name: string; description?: string; properties: ValueProperty[]; validationRules: ValidationRule[]; } interface AggregateProperty { id: string; name: string; type: PropertyType; description?: string; isRequired: boolean; isCollection: boolean; constraints?: PropertyConstraint[]; } interface AggregateMethod { id: string; name: string; description?: string; parameters: MethodParameter[]; returnType?: string; businessRule?: string; emittedEvents: string[]; } interface MethodParameter { name: string; type: PropertyType; isRequired: boolean; description?: string; } interface ValueProperty { id: string; name: string; type: PropertyType; description?: string; isRequired: boolean; constraints?: PropertyConstraint[]; } interface ValidationRule { id: string; description: string; expression: string; errorMessage: string; } interface PropertyConstraint { type: 'min_length' | 'max_length' | 'min_value' | 'max_value' | 'pattern' | 'custom'; value: string | number; description?: string; } type PropertyType = 'string' | 'number' | 'boolean' | 'date' | 'uuid' | 'email' | 'url' | { valueObject: string; } | { entity: string; } | { enum: string[]; }; interface AggregateProperties { boundedContextId: string; name: string; description?: string; responsibility: string; rootEntity: AggregateEntity; childEntities: AggregateEntity[]; valueObjects: ValueObjectDefinition[]; businessInvariantIds: string[]; domainEventsIds: string[]; ubiquitousLanguageTerms: string[]; } declare class Aggregate { readonly id: string; readonly createdAt: Date; private _updatedAt; private _boundedContextId; private _name; private _description?; private _responsibility; private _rootEntity; private _childEntities; private _valueObjects; private _businessInvariantIds; private _domainEventsIds; private _ubiquitousLanguageTerms; private constructor(); static create(properties: AggregateProperties): Aggregate; static reconstitute(properties: AggregateProperties, id: string, createdAt: Date, updatedAt: Date): Aggregate; get boundedContextId(): string; get name(): string; get description(): string | undefined; get responsibility(): string; get rootEntity(): AggregateEntity; get childEntities(): AggregateEntity[]; get valueObjects(): ValueObjectDefinition[]; get businessInvariantIds(): string[]; get domainEventIds(): string[]; get ubiquitousLanguageTerms(): string[]; get updatedAt(): Date; updateName(name: string): void; updateDescription(description?: string): void; updateResponsibility(responsibility: string): void; addChildEntity(entity: AggregateEntity): void; removeChildEntity(entityId: string): void; addValueObject(valueObject: ValueObjectDefinition): void; removeValueObject(valueObjectId: string): void; addBusinessInvariant(businessInvariantId: string): void; removeBusinessInvariant(businessInvariantId: string): void; addDomainEvent(domainEventId: string): void; removeDomainEvent(domainEventId: string): void; addUbiquitousLanguageTerm(term: string): void; removeUbiquitousLanguageTerm(term: string): void; getComplexityScore(): number; getCohesionScore(): number; private touch; private validateInvariants; toJSON(): { id: string; boundedContextId: string; name: string; description: string | undefined; responsibility: string; rootEntity: AggregateEntity; childEntities: AggregateEntity[]; valueObjects: ValueObjectDefinition[]; businessInvariantIds: string[]; domainEventsIds: string[]; ubiquitousLanguageTerms: string[]; complexityScore: number; cohesionScore: number; createdAt: Date; updatedAt: Date; }; } /** * Tactical Design Domain Model * * Represents the complete tactical design for a bounded context, * encompassing all DDD tactical patterns and their relationships. * Provides analysis and validation capabilities for tactical model quality. */ interface TacticalPattern { id: string; name: string; type: 'repository' | 'domain_service' | 'application_service' | 'factory' | 'specification'; description?: string; relatedAggregates: string[]; implementation?: string; } interface DomainService { id: string; name: string; description?: string; responsibility: string; operations: DomainServiceOperation[]; collaboratesWithAggregates: string[]; } interface DomainServiceOperation { id: string; name: string; description?: string; parameters: OperationParameter[]; returnType?: string; businessRule?: string; } interface OperationParameter { name: string; type: string; isRequired: boolean; description?: string; } interface TacticalAnalysis { aggregateComplexity: { aggregateId: string; score: number; issues: string[]; }[]; domainServiceCohesion: { serviceId: string; score: number; recommendations: string[]; }[]; patternUsage: { pattern: string; count: number; appropriateness: 'good' | 'excessive' | 'insufficient'; }[]; boundaryViolations: string[]; recommendations: TacticalRecommendation[]; } interface TacticalRecommendation { category: 'aggregate_design' | 'service_design' | 'pattern_application' | 'boundary_refinement'; priority: 'low' | 'medium' | 'high' | 'critical'; description: string; rationale: string; actionItems: string[]; affectedElements: string[]; } interface TacticalDesignProperties { boundedContextId: string; name: string; description?: string; aggregates: string[]; domainServices: DomainService[]; tacticalPatterns: TacticalPattern[]; architecturalDecisions: ArchitecturalDecision[]; designRationale: string; } interface ArchitecturalDecision { id: string; title: string; description: string; decision: string; rationale: string; consequences: string[]; alternatives: string[]; status: 'proposed' | 'accepted' | 'deprecated' | 'superseded'; decisionDate: Date; decisionMakers: string[]; } declare class TacticalDesign { readonly id: string; readonly createdAt: Date; private _updatedAt; private _boundedContextId; private _name; private _description?; private _aggregateIds; private _domainServices; private _tacticalPatterns; private _architecturalDecisions; private _designRationale; private constructor(); static create(properties: TacticalDesignProperties): TacticalDesign; static reconstitute(properties: TacticalDesignProperties, id: string, createdAt: Date, updatedAt: Date): TacticalDesign; get boundedContextId(): string; get name(): string; get description(): string | undefined; get aggregateIds(): string[]; get domainServices(): DomainService[]; get tacticalPatterns(): TacticalPattern[]; get architecturalDecisions(): ArchitecturalDecision[]; get designRationale(): string; get updatedAt(): Date; updateName(name: string): void; updateDescription(description?: string): void; updateDesignRationale(rationale: string): void; addAggregate(aggregateId: string): void; removeAggregate(aggregateId: string): void; addDomainService(service: DomainService): void; removeDomainService(serviceId: string): void; addTacticalPattern(pattern: TacticalPattern): void; removeTacticalPattern(patternId: string): void; addArchitecturalDecision(decision: ArchitecturalDecision): void; updateArchitecturalDecisionStatus(decisionId: string, status: ArchitecturalDecision['status']): void; analyzeTacticalDesign(): TacticalAnalysis; private analyzeAggregateComplexity; private analyzeDomainServiceCohesion; private analyzePatternUsage; private detectBoundaryViolations; private generateRecommendations; private touch; private validateInvariants; toJSON(): { id: string; boundedContextId: string; name: string; description: string | undefined; aggregateIds: string[]; domainServices: DomainService[]; tacticalPatterns: TacticalPattern[]; architecturalDecisions: ArchitecturalDecision[]; designRationale: string; analysis: TacticalAnalysis; createdAt: Date; updatedAt: Date; }; } interface DomainProperties { name: string; description?: string; vision?: string; ubiquitousLanguage: Record<string, string>; } declare class Domain { readonly id: string; readonly createdAt: Date; private _updatedAt; private _name; private _description?; private _vision?; private _ubiquitousLanguage; private constructor(); static create(properties: DomainProperties): Domain; static reconstitute(properties: DomainProperties, id: string, createdAt: Date, updatedAt: Date): Domain; get name(): string; get description(): string | undefined; get vision(): string | undefined; get ubiquitousLanguage(): Record<string, string>; get updatedAt(): Date; updateName(name: string): void; updateDescription(description?: string): void; updateVision(vision?: string): void; addUbiquitousLanguageTerm(term: string, definition: string): void; removeUbiquitousLanguageTerm(term: string): void; private touch; private validateInvariants; toJSON(): { id: string; name: string; description: string | undefined; vision: string | undefined; ubiquitousLanguage: Record<string, string>; createdAt: Date; updatedAt: Date; }; } interface DomainModelElement { id: string; name: string; description?: string; } interface BoundedContextProperties { domainId: string; name: string; description?: string; type: 'core' | 'supporting' | 'generic'; ubiquitousLanguage: Record<string, string>; domainServices: DomainModelElement[]; aggregates: DomainModelElement[]; valueObjects: DomainModelElement[]; entities: DomainModelElement[]; } declare class BoundedContext { readonly id: string; readonly createdAt: Date; private _updatedAt; private _domainId; private _name; private _description?; private _type; private _ubiquitousLanguage; private _domainServices; private _aggregates; private _valueObjects; private _entities; private constructor(); static create(properties: BoundedContextProperties): BoundedContext; static reconstitute(properties: BoundedContextProperties, id: string, createdAt: Date, updatedAt: Date): BoundedContext; get domainId(): string; get name(): string; get description(): string | undefined; get type(): 'core' | 'supporting' | 'generic'; get ubiquitousLanguage(): Record<string, string>; get domainServices(): DomainModelElement[]; get aggregates(): DomainModelElement[]; get valueObjects(): DomainModelElement[]; get entities(): DomainModelElement[]; get updatedAt(): Date; updateName(name: string): void; updateDescription(description?: string): void; updateType(type: 'core' | 'supporting' | 'generic'): void; addUbiquitousLanguageTerm(term: string, definition: string): void; removeUbiquitousLanguageTerm(term: string): void; addDomainService(service: DomainModelElement): void; removeDomainService(serviceId: string): void; addAggregate(aggregate: DomainModelElement): void; removeAggregate(aggregateId: string): void; addValueObject(valueObject: DomainModelElement): void; removeValueObject(valueObjectId: string): void; addEntity(entity: DomainModelElement): void; removeEntity(entityId: string): void; private touch; private validateInvariants; toJSON(): { id: string; domainId: string; name: string; description: string | undefined; type: "core" | "supporting" | "generic"; ubiquitousLanguage: Record<string, string>; domainServices: DomainModelElement[]; aggregates: DomainModelElement[]; valueObjects: DomainModelElement[]; entities: DomainModelElement[]; createdAt: Date; updatedAt: Date; }; } interface ProjectProperties { name: string; description: string; domainId: string; boundedContextId?: string; metadata?: Record<string, unknown>; } declare class Project { readonly id: string; readonly createdAt: Date; private _updatedAt; private _name; private _description; private _domainId; private _boundedContextId?; private _metadata; private constructor(); static create(properties: ProjectProperties): Project; static reconstitute(properties: ProjectProperties, id: string, createdAt: Date, updatedAt: Date): Project; get name(): string; get description(): string; get domainId(): string; get boundedContextId(): string | undefined; get metadata(): Record<string, unknown>; get updatedAt(): Date; updateName(name: string): void; updateDescription(description: string): void; updateBoundedContext(boundedContextId?: string): void; updateMetadata(metadata: Record<string, unknown>): void; private touch; private validateInvariants; toJSON(): { id: string; name: string; description: string; domainId: string; boundedContextId: string | undefined; metadata: Record<string, unknown>; createdAt: Date; updatedAt: Date; }; } /** * Package Mapping Entity * * Domain entity representing the mapping of a package to a strategic domain. * Encapsulates package classification, confidence scoring, and mapping status. */ declare class PackageMapping { private readonly _id; private readonly _packageName; private readonly _packageType; private _domainId; private _classification; private _status; private readonly _createdAt; private _updatedAt; private _lastReviewedBy; private _notes; private constructor(); static create(packageName: string, packageType: PackageType, domainId?: string, classification?: PackageClassification): PackageMapping; static reconstitute(id: string, packageName: string, packageType: PackageType, domainId: string | null, classification: PackageClassification, status: MappingStatus, createdAt: Date, updatedAt: Date, lastReviewedBy?: string, notes?: string): PackageMapping; get id(): string; get packageName(): string; get packageType(): PackageType; get domainId(): string | null; get classification(): PackageClassification; get status(): MappingStatus; get createdAt(): Date; get updatedAt(): Date; get lastReviewedBy(): string | null; get notes(): string | null; assignToDomain(domainId: string, reviewedBy?: string): void; markAsOrphaned(): void; markForReview(reason?: string): void; markAsDisputed(reason: string): void; updateClassification(classification: PackageClassification): void; addNotes(notes: string, reviewedBy?: string): void; isWellAligned(): boolean; needsAttention(): boolean; } declare enum PackageType { DOMAIN = "domain", API = "api", SERVICE = "service", APP = "app", SHARED = "shared", INFRASTRUCTURE = "infrastructure" } declare enum MappingStatus { ALIGNED = "aligned", ORPHANED = "orphaned", NEEDS_REVIEW = "needs_review", DISPUTED = "disputed" } interface PackageClassification { confidence: number; reasoning: string; suggestedDomain?: string | null; automaticallyClassified: boolean; } interface PackageAnalysis { packageName: string; suggestedDomains: Array<{ domainId: string; domainName: string; confidence: number; reasoning: string; }>; packageType: PackageType; complexity: 'low' | 'medium' | 'high'; recommendations: string[]; } /** * Package Mapping Repository Interface * * Port for package mapping persistence operations. * Follows Repository pattern from Domain-Driven Design. */ interface IPackageMappingRepository { /** * Save a package mapping */ save(mapping: PackageMapping): Promise<void>; /** * Find package mapping by package name */ findByPackageName(packageName: string): Promise<PackageMapping | null>; /** * Find package mappings by domain ID */ findByDomainId(domainId: string): Promise<PackageMapping[]>; /** * Find package mappings by status */ findByStatus(status: MappingStatus): Promise<PackageMapping[]>; /** * Find package mappings by type */ findByPackageType(packageType: PackageType): Promise<PackageMapping[]>; /** * Find all package mappings with filtering and pagination */ findAll(filters: PackageMappingFilters): Promise<{ mappings: PackageMapping[]; total: number; }>; /** * Delete package mapping by package name */ deleteByPackageName(packageName: string): Promise<void>; /** * Bulk save package mappings */ bulkSave(mappings: PackageMapping[]): Promise<void>; /** * Check if package mapping exists */ exists(packageName: string): Promise<boolean>; /** * Get mapping statistics */ getStatistics(): Promise<PackageMappingStatistics>; } interface PackageMappingFilters { domainId?: string; status?: MappingStatus; packageType?: PackageType; search?: string; limit?: number; offset?: number; } interface PackageMappingStatistics { totalMappings: number; alignedCount: number; orphanedCount: number; needsReviewCount: number; disputedCount: number; byPackageType: Record<PackageType, number>; averageConfidence: number; } /** * Bounded Context Pattern - Domain Entity * * Represents the meta-model of a bounded context pattern including its structure, * dependencies, and compliance with architectural standards. * * Following Eric Evans DDD principles for meta-modeling domain architecture. */ declare class BoundedContextPatternId extends EntityId { private readonly value; constructor(value: string); static generate(): BoundedContextPatternId; static fromString(value: string): BoundedContextPatternId; toString(): string; } declare const BoundedContextTypeSchema: z.ZodEnum<["core", "supporting", "generic"]>; type BoundedContextType = z.infer<typeof BoundedContextTypeSchema>; declare const ModulePatternTypeSchema: z.ZodEnum<["createXModule", "static-configure", "no-module"]>; type ModulePatternType = z.infer<typeof ModulePatternTypeSchema>; declare const ArchitecturalPatternSchema: z.ZodObject<{ hasCleanArchitecture: z.ZodBoolean; hasPortsAndAdapters: z.ZodBoolean; hasCQRS: z.ZodBoolean; hasEventSourcing: z.ZodBoolean; hasDomainEvents: z.ZodBoolean; hasAntiCorruptionLayer: z.ZodBoolean; }, "strip", z.ZodTypeAny, { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }, { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }>; type ArchitecturalPattern = z.infer<typeof ArchitecturalPatternSchema>; declare const DependencyAnalysisSchema: z.ZodObject<{ inboundDependencies: z.ZodArray<z.ZodString, "many">; outboundDependencies: z.ZodArray<z.ZodString, "many">; circularDependencies: z.ZodArray<z.ZodString, "many">; violatesCleanArchitecture: z.ZodBoolean; }, "strip", z.ZodTypeAny, { inboundDependencies: string[]; outboundDependencies: string[]; circularDependencies: string[]; violatesCleanArchitecture: boolean; }, { inboundDependencies: string[]; outboundDependencies: string[]; circularDependencies: string[]; violatesCleanArchitecture: boolean; }>; type DependencyAnalysis = z.infer<typeof DependencyAnalysisSchema>; declare const ComplianceScoreSchema: z.ZodObject<{ overall: z.ZodNumber; modulePattern: z.ZodNumber; symbolUsage: z.ZodNumber; architecturalCompliance: z.ZodNumber; dependencyHealth: z.ZodNumber; }, "strip", z.ZodTypeAny, { overall: number; modulePattern: number; symbolUsage: number; architecturalCompliance: number; dependencyHealth: number; }, { overall: number; modulePattern: number; symbolUsage: number; architecturalCompliance: number; dependencyHealth: number; }>; type ComplianceScore = z.infer<typeof ComplianceScoreSchema>; declare const BoundedContextPatternSchema: z.ZodObject<{ id: z.ZodString; packageName: z.ZodString; contextName: z.ZodString; contextType: z.ZodEnum<["core", "supporting", "generic"]>; modulePatternType: z.ZodEnum<["createXModule", "static-configure", "no-module"]>; hasSymbolConstants: z.ZodBoolean; symbolConstantName: z.ZodOptional<z.ZodString>; architecturalPatterns: z.ZodObject<{ hasCleanArchitecture: z.ZodBoolean; hasPortsAndAdapters: z.ZodBoolean; hasCQRS: z.ZodBoolean; hasEventSourcing: z.ZodBoolean; hasDomainEvents: z.ZodBoolean; hasAntiCorruptionLayer: z.ZodBoolean; }, "strip", z.ZodTypeAny, { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }, { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }>; dependencyAnalysis: z.ZodObject<{ inboundDependencies: z.ZodArray<z.ZodString, "many">; outboundDependencies: z.ZodArray<z.ZodString, "many">; circularDependencies: z.ZodArray<z.ZodString, "many">; violatesCleanArchitecture: z.ZodBoolean; }, "strip", z.ZodTypeAny, { inboundDependencies: string[]; outboundDependencies: string[]; circularDependencies: string[]; violatesCleanArchitecture: boolean; }, { inboundDependencies: string[]; outboundDependencies: string[]; circularDependencies: string[]; violatesCleanArchitecture: boolean; }>; complianceScore: z.ZodObject<{ overall: z.ZodNumber; modulePattern: z.ZodNumber; symbolUsage: z.ZodNumber; architecturalCompliance: z.ZodNumber; dependencyHealth: z.ZodNumber; }, "strip", z.ZodTypeAny, { overall: number; modulePattern: number; symbolUsage: number; architecturalCompliance: number; dependencyHealth: number; }, { overall: number; modulePattern: number; symbolUsage: number; architecturalCompliance: number; dependencyHealth: number; }>; lastAnalyzedAt: z.ZodDate; createdAt: z.ZodDate; updatedAt: z.ZodDate; }, "strip", z.ZodTypeAny, { id: string; packageName: string; contextName: string; contextType: "core" | "supporting" | "generic"; modulePatternType: "createXModule" | "static-configure" | "no-module"; hasSymbolConstants: boolean; architecturalPatterns: { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }; dependencyAnalysis: { inboundDependencies: string[]; outboundDependencies: string[]; circularDependencies: string[]; violatesCleanArchitecture: boolean; }; complianceScore: { overall: number; modulePattern: number; symbolUsage: number; architecturalCompliance: number; dependencyHealth: number; }; lastAnalyzedAt: Date; createdAt: Date; updatedAt: Date; symbolConstantName?: string | undefined; }, { id: string; packageName: string; contextName: string; contextType: "core" | "supporting" | "generic"; modulePatternType: "createXModule" | "static-configure" | "no-module"; hasSymbolConstants: boolean; architecturalPatterns: { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }; dependencyAnalysis: { inboundDependencies: string[]; outboundDependencies: string[]; circularDependencies: string[]; violatesCleanArchitecture: boolean; }; complianceScore: { overall: number; modulePattern: number; symbolUsage: number; architecturalCompliance: number; dependencyHealth: number; }; lastAnalyzedAt: Date; createdAt: Date; updatedAt: Date; symbolConstantName?: string | undefined; }>; type BoundedContextPatternData = z.infer<typeof BoundedContextPatternSchema>; /** * Bounded Context Pattern Entity * * Aggregate root for meta-model analysis of bounded contexts. * Provides insights into architectural compliance and pattern consistency. */ declare class BoundedContextPattern extends Entity<BoundedContextPatternId> { private readonly _packageName; private readonly _contextName; private readonly _contextType; private _modulePatternType; private _hasSymbolConstants; private _symbolConstantName; private _architecturalPatterns; private _dependencyAnalysis; private _complianceScore; private _lastAnalyzedAt; private readonly _createdAt; private _updatedAt; private constructor(); static create(data: Omit<BoundedContextPatternData, 'id' | 'createdAt' | 'updatedAt'>): BoundedContextPattern; static fromData(data: BoundedContextPatternData): BoundedContextPattern; get packageName(): string; get contextName(): string; get contextType(): BoundedContextType; get modulePatternType(): ModulePatternType; get hasSymbolConstants(): boolean; get symbolConstantName(): string | undefined; get architecturalPatterns(): ArchitecturalPattern; get dependencyAnalysis(): DependencyAnalysis; get complianceScore(): ComplianceScore; get lastAnalyzedAt(): Date; get createdAt(): Date; get updatedAt(): Date; /** * Update analysis results */ updateAnalysis(modulePatternType: ModulePatternType, hasSymbolConstants: boolean, symbolConstantName: string | undefined, architecturalPatterns: ArchitecturalPattern, dependencyAnalysis: DependencyAnalysis): void; /** * Calculate compliance score based on patterns and architecture */ private calculateComplianceScore; /** * Check if context follows recommended patterns */ isCompliant(): boolean; /** * Get recommendations for improvement */ getRecommendations(): string[]; /** * Convert to plain data object */ toData(): BoundedContextPatternData; } /** * Architectural Analysis - Domain Entity * * Represents a comprehensive analysis of monorepo architecture including * bounded context relationships, dependency health, and pattern compliance. * * Following Eric Evans DDD principles for meta-modeling system architecture. */ declare class ArchitecturalAnalysisId extends EntityId { private readonly value; constructor(value: string); static generate(): ArchitecturalAnalysisId; static fromString(value: string): ArchitecturalAnalysisId; toString(): string; } declare const MonorepoHealthSchema: z.ZodObject<{ totalPackages: z.ZodNumber; totalBoundedContexts: z.ZodNumber; compliantContexts: z.ZodNumber; nonCompliantContexts: z.ZodNumber; averageComplianceScore: z.ZodNumber; }, "strip", z.ZodTypeAny, { totalPackages: number; totalBoundedContexts: number; compliantContexts: number; nonCompliantContexts: number; averageComplianceScore: number; }, { totalPackages: number; totalBoundedContexts: number; compliantContexts: number; nonCompliantContexts: number; averageComplianceScore: number; }>; type MonorepoHealth = z.infer<typeof MonorepoHealthSchema>; declare const DependencyGraphSchema: z.ZodObject<{ nodes: z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodString; type: z.ZodEnum<["core", "supporting", "generic"]>; complianceScore: z.ZodNumber; }, "strip", z.ZodTypeAny, { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }, { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }>, "many">; edges: z.ZodArray<z.ZodObject<{ source: z.ZodString; target: z.ZodString; type: z.ZodEnum<["depends-on", "publishes-to", "subscribes-to"]>; }, "strip", z.ZodTypeAny, { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }, { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }>, "many">; cycles: z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">; }, "strip", z.ZodTypeAny, { nodes: { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }[]; edges: { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }[]; cycles: string[][]; }, { nodes: { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }[]; edges: { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }[]; cycles: string[][]; }>; type DependencyGraph = z.infer<typeof DependencyGraphSchema>; declare const PatternComplianceSchema: z.ZodObject<{ modulePatternCompliance: z.ZodNumber; symbolUsageCompliance: z.ZodNumber; cleanArchitectureCompliance: z.ZodNumber; portsAdaptersCompliance: z.ZodNumber; }, "strip", z.ZodTypeAny, { modulePatternCompliance: number; symbolUsageCompliance: number; cleanArchitectureCompliance: number; portsAdaptersCompliance: number; }, { modulePatternCompliance: number; symbolUsageCompliance: number; cleanArchitectureCompliance: number; portsAdaptersCompliance: number; }>; type PatternCompliance = z.infer<typeof PatternComplianceSchema>; declare const RecommendationSchema: z.ZodObject<{ id: z.ZodString; priority: z.ZodEnum<["high", "medium", "low"]>; category: z.ZodEnum<["module-pattern", "symbol-usage", "architecture", "dependencies"]>; title: z.ZodString; description: z.ZodString; affectedPackages: z.ZodArray<z.ZodString, "many">; estimatedEffort: z.ZodEnum<["low", "medium", "high"]>; }, "strip", z.ZodTypeAny, { id: string; priority: "low" | "medium" | "high"; category: "module-pattern" | "symbol-usage" | "architecture" | "dependencies"; title: string; description: string; affectedPackages: string[]; estimatedEffort: "low" | "medium" | "high"; }, { id: string; priority: "low" | "medium" | "high"; category: "module-pattern" | "symbol-usage" | "architecture" | "dependencies"; title: string; description: string; affectedPackages: string[]; estimatedEffort: "low" | "medium" | "high"; }>; type Recommendation = z.infer<typeof RecommendationSchema>; declare const ArchitecturalAnalysisSchema: z.ZodObject<{ id: z.ZodString; monorepoPath: z.ZodString; analysisType: z.ZodEnum<["full", "incremental", "targeted"]>; monorepoHealth: z.ZodObject<{ totalPackages: z.ZodNumber; totalBoundedContexts: z.ZodNumber; compliantContexts: z.ZodNumber; nonCompliantContexts: z.ZodNumber; averageComplianceScore: z.ZodNumber; }, "strip", z.ZodTypeAny, { totalPackages: number; totalBoundedContexts: number; compliantContexts: number; nonCompliantContexts: number; averageComplianceScore: number; }, { totalPackages: number; totalBoundedContexts: number; compliantContexts: number; nonCompliantContexts: number; averageComplianceScore: number; }>; dependencyGraph: z.ZodObject<{ nodes: z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodString; type: z.ZodEnum<["core", "supporting", "generic"]>; complianceScore: z.ZodNumber; }, "strip", z.ZodTypeAny, { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }, { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }>, "many">; edges: z.ZodArray<z.ZodObject<{ source: z.ZodString; target: z.ZodString; type: z.ZodEnum<["depends-on", "publishes-to", "subscribes-to"]>; }, "strip", z.ZodTypeAny, { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }, { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }>, "many">; cycles: z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">; }, "strip", z.ZodTypeAny, { nodes: { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }[]; edges: { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }[]; cycles: string[][]; }, { nodes: { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }[]; edges: { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }[]; cycles: string[][]; }>; patternCompliance: z.ZodObject<{ modulePatternCompliance: z.ZodNumber; symbolUsageCompliance: z.ZodNumber; cleanArchitectureCompliance: z.ZodNumber; portsAdaptersCompliance: z.ZodNumber; }, "strip", z.ZodTypeAny, { modulePatternCompliance: number; symbolUsageCompliance: number; cleanArchitectureCompliance: number; portsAdaptersCompliance: number; }, { modulePatternCompliance: number; symbolUsageCompliance: number; cleanArchitectureCompliance: number; portsAdaptersCompliance: number; }>; recommendations: z.ZodArray<z.ZodObject<{ id: z.ZodString; priority: z.ZodEnum<["high", "medium", "low"]>; category: z.ZodEnum<["module-pattern", "symbol-usage", "architecture", "dependencies"]>; title: z.ZodString; description: z.ZodString; affectedPackages: z.ZodArray<z.ZodString, "many">; estimatedEffort: z.ZodEnum<["low", "medium", "high"]>; }, "strip", z.ZodTypeAny, { id: string; priority: "low" | "medium" | "high"; category: "module-pattern" | "symbol-usage" | "architecture" | "dependencies"; title: string; description: string; affectedPackages: string[]; estimatedEffort: "low" | "medium" | "high"; }, { id: string; priority: "low" | "medium" | "high"; category: "module-pattern" | "symbol-usage" | "architecture" | "dependencies"; title: string; description: string; affectedPackages: string[]; estimatedEffort: "low" | "medium" | "high"; }>, "many">; analysisStartedAt: z.ZodDate; analysisCompletedAt: z.ZodDate; analysisDurationMs: z.ZodNumber; createdAt: z.ZodDate; }, "strip", z.ZodTypeAny, { id: string; createdAt: Date; monorepoPath: string; analysisType: "full" | "incremental" | "targeted"; monorepoHealth: { totalPackages: number; totalBoundedContexts: number; compliantContexts: number; nonCompliantContexts: number; averageComplianceScore: number; }; dependencyGraph: { nodes: { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }[]; edges: { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }[]; cycles: string[][]; }; patternCompliance: { modulePatternCompliance: number; symbolUsageCompliance: number; cleanArchitectureCompliance: number; portsAdaptersCompliance: number; }; recommendations: { id: string; priority: "low" | "medium" | "high"; category: "module-pattern" | "symbol-usage" | "architecture" | "dependencies"; title: string; description: string; affectedPackages: string[]; estimatedEffort: "low" | "medium" | "high"; }[]; analysisStartedAt: Date; analysisCompletedAt: Date; analysisDurationMs: number; }, { id: string; createdAt: Date; monorepoPath: string; analysisType: "full" | "incremental" | "targeted"; monorepoHealth: { totalPackages: number; totalBoundedContexts: number; compliantContexts: number; nonCompliantContexts: number; averageComplianceScore: number; }; dependencyGraph: { nodes: { type: "core" | "supporting" | "generic"; id: string; complianceScore: number; name: string; }[]; edges: { type: "depends-on" | "publishes-to" | "subscribes-to"; source: string; target: string; }[]; cycles: string[][]; }; patternCompliance: { modulePatternCompliance: number; symbolUsageCompliance: number; cleanArchitectureCompliance: number; portsAdaptersCompliance: number; }; recommendations: { id: string; priority: "low" | "medium" | "high"; category: "module-pattern" | "symbol-usage" | "architecture" | "dependencies"; title: string; description: string; affectedPackages: string[]; estimatedEffort: "low" | "medium" | "high"; }[]; analysisStartedAt: Date; analysisCompletedAt: Date; analysisDurationMs: number; }>; type ArchitecturalAnalysisData = z.infer<typeof ArchitecturalAnalysisSchema>; /** * Architectural Analysis Entity * * Aggregate root for meta-model analysis of entire monorepo architecture. * Provides comprehensive insights into architectural health and compliance. */ declare class ArchitecturalAnalysis extends Entity<ArchitecturalAnalysisId> { private readonly _monorepoPath; private readonly _analysisType; private _monorepoHealth; private _dependencyGraph; private _patternCompliance; private _recommendations; private readonly _analysisStartedAt; private _analysisCompletedAt; private _analysisDurationMs; private readonly _createdAt; private constructor(); static create(monorepoPath: string, analysisType: 'full' | 'incremental' | 'targeted'): ArchitecturalAnalysis; static fromData(data: ArchitecturalAnalysisData): ArchitecturalAnalysis; get monorepoPath(): string; get analysisType(): 'full' | 'incremental' | 'targeted'; get monorepoHealth(): MonorepoHealth; get dependencyGraph(): DependencyGraph; get patternCompliance(): PatternCompliance; get recommendations(): Recommendation[]; get analysisStartedAt(): Date; get analysisCompletedAt(): Date; get analysisDurationMs(): number; get createdAt(): Date; /** * Complete the analysis with results */ completeAnalysis(monorepoHealth: MonorepoHealth, dependencyGraph: DependencyGraph, patternCompliance: PatternCompliance, recommendations: Recommendation[]): void; /** * Get overall health score */ getOverallHealthScore(): number; /** * Get high priority recommendations */ getHighPriorityRecommendations(): Recommendation[]; /** * Get recommendations by category */ getRecommendationsByCategory(category: Recommendation['category']): Recommendation[]; /** * Check if monorepo has circular dependencies */ hasCircularDependencies(): boolean; /** * Get packages involved in circular dependencies */ getCircularDependencyPackages(): string[]; /** * Check if monorepo meets architectural standards */ meetsArchitecturalStandards(): boolean; /** * Get summary for reporting */ getSummary(): { overallHealth: number; totalPackages: number; compliantPackages: number; highPriorityIssues: number; circularDependencies: number; meetsStandards: boolean; }; /** * Convert to plain data object */ toData(): ArchitecturalAnalysisData; } /** * Meta-Model Analysis Port * * Hexagonal Architecture port for meta-model analysis capabilities. * Defines the contract for analyzing bounded context patterns and architecture. */ /** * Package Analysis Result */ interface PackageAnalysisResult { packageName: string; contextName: string; contextType: 'core' | 'supporting' | 'generic'; modulePatternType: 'createXModule' | 'static-configure' | 'no-module'; hasSymbolConstants: boolean; symbolConstantName?: string; architecturalPatterns: { hasCleanArchitecture: boolean; hasPortsAndAdapters: boolean; hasCQRS: boolean; hasEventSourcing: boolean; hasDomainEvents: boolean; hasAntiCorruptionLayer: boolean; }; dependencies: string[]; fileAnalysis: { totalFiles: number; domainFiles: number; applicationFiles: number; infrastructureFiles: number; interfaceFiles: number; }; } /** * Dependency Graph Result */ interface DependencyGraphResult { nodes: Array<{ id: string; name: string; type: 'core' | 'supporting' | 'generic'; complianceScore: number; }>; edges: Array<{ source: string; target: string; type: 'depends-on' | 'publishes-to' | 'subscribes-to'; }>; cycles: string[][]; } /** * Pattern Compliance Summary */ interface PatternComplianceSummary { totalPackages: number; compliantPackages: number; modulePatternCompliance: number; symbolUsageCompliance: number; architecturalCompliance: number; recommendations: Array<{ priority: 'high' | 'medium' | 'low'; category: string; description: string; affectedPackages: string[]; }>; } /** * Meta-Model Analysis Port Interface * * Provides meta-model analysis capabilities for bounded contexts and architecture. * Implementations will be provided by infrastructure adapters (MCP, CLI, Web, etc.). */ interface IMetaModelAnalysisPort { /** * Analyze a single package for bounded context patterns */ analyzePackage(packagePath: string): Promise<PackageAnalysisResult>; /** * Scan monorepo for all packages */ scanMonorepo(monorepoPath: string): Promise<string[]>; /** * Analyze dependencies between packages */ analyzeDependencies(packages: string[]): Promise<DependencyGraphResult>; /** * Get pattern compliance summary */ getPatternCompliance(packages?: string[]): Promise<PatternComplianceSummary>; /** * Validate architecture against DDD principles */ validateArchitecture(monorepoPath: string): Promise<{ isValid: boolean; violations: Array<{ type: string; description: string; severity: 'error' | 'warning' | 'info'; packages: string[]; }>; score: number; }>; /** * Generate migration recommendations */ generateMigrationPlan(currentState: BoundedContextPatternData[], targetPattern: 'createXModule' | 'ports-adapters' | 'clean-architecture'): Promise<{ steps: Array<{ order: number; title: string; description: string; packages: string[]; estimatedEffort: 'low' | 'medium' | 'high'; dependencies: number[]; }>; totalEstimatedHours: number; }>; /** * Export analysis results */ exportAnalysis(analysis: ArchitecturalAnalysisData, format: 'json' | 'markdown' | 'csv' | 'html'): Promise<string>; } /** * Domain Ports - DI Symbols * * Clean separation of DI symbols from interface types. * Following the systematic pattern to prevent export issues. */ declare const IPackageMappingRepositorySymbol: unique symbol; declare const IMetaModelAnalysisPortSymbol: unique symbol; /** * DDD Domain Integration Module * * This module provides the integration interface for DDD Domain * following Eric Evans Strategic DDD patterns. It exposes the * Published Language contracts that downstream contexts can depend on. * * Integration Patterns: * - Published Language: Stable contracts for downstream contexts * - Customer/Supplier: DDD is upstream, consumers are downstream * - Anti-Corruptio