UNPKG

@swoft/platform-contracts

Version:

DDD-compliant dependency injection contracts for Swoft platform - Defines clean architecture boundaries

141 lines (116 loc) 4.88 kB
/** * Shared Cross-Cutting Contracts * * Defines dependency injection symbols for cross-cutting concerns * that span multiple layers and bounded contexts. */ // ============================================ // NAVIGATION CONTRACTS // ============================================ /** * Navigation and AI-native discovery contracts * Standardizes navigation patterns across MCP servers */ export const NAVIGATION_CONTRACTS = { // Core navigation services NAVIGATION_HINTS_PROVIDER: Symbol('Shared.Navigation.NavigationHintsProvider'), NAVIGATION_HINTS_BUILDER: Symbol('Shared.Navigation.NavigationHintsBuilder'), NAVIGATION_HINTS_FACTORY: Symbol('Shared.Navigation.NavigationHintsFactory'), // Cross-MCP navigation CROSS_MCP_NAVIGATOR: Symbol('Shared.Navigation.CrossMcpNavigator'), MCP_TOOL_REGISTRY: Symbol('Shared.Navigation.McpToolRegistry'), // Context awareness WORKFLOW_CONTEXT_PROVIDER: Symbol('Shared.Navigation.WorkflowContextProvider'), GIT_CONTEXT_PROVIDER: Symbol('Shared.Navigation.GitContextProvider'), // Navigation enhancement NAVIGATION_PROCESSOR: Symbol('Shared.Navigation.NavigationProcessor'), NAVIGATION_FILTER: Symbol('Shared.Navigation.NavigationFilter'), // Semantic navigation SEMANTIC_NAVIGATION_REGISTRY: Symbol('Shared.Navigation.SemanticNavigationRegistry'), SEMANTIC_HINTS_FACTORY: Symbol('Shared.Navigation.SemanticHintsFactory'), DOMAIN_SEMANTICS_PROVIDER: Symbol('Shared.Navigation.DomainSemanticsProvider'), } as const; // ============================================ // LOGGING & MONITORING CONTRACTS // ============================================ /** * Logging and observability contracts * Used across all layers for consistent logging */ export const LOGGING_CONTRACTS = { // Core logging LOGGER: Symbol('Shared.Logging.Logger'), BOUNDED_CONTEXT_LOGGER: Symbol('Shared.Logging.BoundedContextLogger'), LAYER_LOGGER: Symbol('Shared.Logging.LayerLogger'), // Performance monitoring PERFORMANCE_MONITOR: Symbol('Shared.Monitoring.PerformanceMonitor'), METRICS_COLLECTOR: Symbol('Shared.Monitoring.MetricsCollector'), // Health checks HEALTH_CHECK_SERVICE: Symbol('Shared.Health.HealthCheckService'), DISK_HEALTH_MONITOR: Symbol('Shared.Health.DiskHealthMonitor'), } as const; // ============================================ // SECURITY & AUTHORIZATION CONTRACTS // ============================================ /** * Security and authorization contracts * Cross-cutting security concerns */ export const SECURITY_CONTRACTS = { // Authentication AUTHENTICATION_SERVICE: Symbol('Shared.Security.AuthenticationService'), TOKEN_VALIDATOR: Symbol('Shared.Security.TokenValidator'), // Authorization AUTHORIZATION_SERVICE: Symbol('Shared.Security.AuthorizationService'), PERMISSION_CHECKER: Symbol('Shared.Security.PermissionChecker'), // Audit AUDIT_LOGGER: Symbol('Shared.Security.AuditLogger'), SECURITY_EVENT_PUBLISHER: Symbol('Shared.Security.SecurityEventPublisher'), } as const; // ============================================ // CONFIGURATION CONTRACTS // ============================================ /** * Configuration and environment contracts * Centralized configuration management */ export const CONFIGURATION_CONTRACTS = { // Core configuration SERVER_CONFIG: Symbol('Shared.Config.ServerConfig'), DATABASE_CONFIG: Symbol('Shared.Config.DatabaseConfig'), // Environment-specific DEVELOPMENT_CONFIG: Symbol('Shared.Config.DevelopmentConfig'), PRODUCTION_CONFIG: Symbol('Shared.Config.ProductionConfig'), // Feature flags FEATURE_FLAG_SERVICE: Symbol('Shared.Config.FeatureFlagService'), ENVIRONMENT_DETECTOR: Symbol('Shared.Config.EnvironmentDetector'), } as const; // Type-safe access to shared contracts export type NavigationContract = (typeof NAVIGATION_CONTRACTS)[keyof typeof NAVIGATION_CONTRACTS]; export type LoggingContract = (typeof LOGGING_CONTRACTS)[keyof typeof LOGGING_CONTRACTS]; export type SecurityContract = (typeof SECURITY_CONTRACTS)[keyof typeof SECURITY_CONTRACTS]; export type ConfigurationContract = (typeof CONFIGURATION_CONTRACTS)[keyof typeof CONFIGURATION_CONTRACTS]; // ============================================ // NAVIGATION INTERFACES EXPORT // ============================================ /** * Export all NavigationHints interfaces and types * Making them available for cross-cutting use */ export * from './NavigationHints'; /** * Export all SemanticNavigation interfaces and types * Semantic domain-aware navigation patterns */ export * from './SemanticNavigation'; /** * Export MCP Semantic Startup Enforcer * Mandatory semantic context loading for all MCP servers */ export * from './MCPSemanticStartupEnforcer'; /** * Export Health Check utilities and interfaces * Standard health check patterns for all MCP servers */ export * from './HealthCheck';