UNPKG

@swoft/platform-contracts

Version:

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

943 lines (931 loc) 35.8 kB
/** * Infrastructure Layer Contracts * * Defines dependency injection symbols for infrastructure concerns. * These are the "adapters" in hexagonal architecture - external dependencies * that implement ports defined by inner layers. */ /** * MongoDB Infrastructure Contracts * Used by all packages that need MongoDB access */ declare const INFRASTRUCTURE_CONTRACTS: { readonly MONGO_CLIENT: symbol; readonly DATABASE_NAME: symbol; readonly MONGO_CONNECTION_STRING: symbol; readonly CAS_STORAGE_PORT: symbol; readonly DISK_REGISTRY_PORT: symbol; readonly DISK_ADAPTER_RESOLVER: symbol; readonly S3_CLIENT: symbol; readonly SECRET_MANAGER: symbol; }; type InfrastructureContract = (typeof INFRASTRUCTURE_CONTRACTS)[keyof typeof INFRASTRUCTURE_CONTRACTS]; /** * Domain Layer Contracts * * Defines dependency injection symbols for domain concerns. * These are the "ports" in hexagonal architecture - interfaces defined * by the domain that infrastructure adapters must implement. */ /** * Repository contracts for domain entities * These are ports that infrastructure adapters implement */ declare const DOMAIN_CONTRACTS: { readonly SCHEMA_REPOSITORY: symbol; readonly BUSINESS_ACTION_REPOSITORY: symbol; readonly DOCUMENTATION_REPOSITORY: symbol; readonly ATOMIC_TASK_REPOSITORY: symbol; readonly HANDOFF_REPOSITORY: symbol; readonly MESSAGE_REPOSITORY: symbol; }; /** * Domain service contracts for complex business logic * Services that orchestrate multiple entities/value objects */ declare const DOMAIN_SERVICE_CONTRACTS: { readonly CONTENT_DISCOVERY_SERVICE: symbol; readonly RELATIONSHIP_DISCOVERY_SERVICE: symbol; readonly TASK_ORCHESTRATION_SERVICE: symbol; readonly BUSINESS_ACTION_ORCHESTRATOR: symbol; }; type DomainContract = (typeof DOMAIN_CONTRACTS)[keyof typeof DOMAIN_CONTRACTS]; type DomainServiceContract = (typeof DOMAIN_SERVICE_CONTRACTS)[keyof typeof DOMAIN_SERVICE_CONTRACTS]; /** * Application Layer Contracts * * Defines dependency injection symbols for application concerns. * These orchestrate domain logic and coordinate between bounded contexts. */ /** * Application services that orchestrate domain logic * These coordinate multiple domain services and repositories */ declare const APPLICATION_CONTRACTS: { readonly CAS_SERVICE: symbol; readonly CONTRACT_DISCOVERY_SERVICE: symbol; readonly SCHEMA_APPLICATION_SERVICE: symbol; readonly DOCUMENTATION_APPLICATION_SERVICE: symbol; readonly SERVICE_MANAGER: symbol; readonly SERVICE_REGISTRY: symbol; readonly TASK_ORCHESTRATOR: symbol; readonly SEEDER_MANAGER: symbol; readonly VALIDATION_SERVICE: symbol; }; /** * CQRS infrastructure contracts * Command and Query buses for cross-bounded-context communication */ declare const CQRS_CONTRACTS: { readonly COMMAND_BUS: symbol; readonly COMMAND_HANDLER_REGISTRY: symbol; readonly QUERY_BUS: symbol; readonly QUERY_HANDLER_REGISTRY: symbol; readonly EVENT_BUS: symbol; readonly EVENT_HANDLER_REGISTRY: symbol; }; /** * Use case contracts for specific business operations * These represent specific user intentions/stories */ declare const USE_CASE_CONTRACTS: { readonly START_SERVICE_USE_CASE: symbol; readonly STOP_SERVICE_USE_CASE: symbol; readonly LIST_SERVICES_USE_CASE: symbol; readonly CREATE_DOCUMENTATION_USE_CASE: symbol; readonly UPDATE_DOCUMENTATION_USE_CASE: symbol; readonly PUBLISH_DOCUMENTATION_USE_CASE: symbol; }; type ApplicationContract = (typeof APPLICATION_CONTRACTS)[keyof typeof APPLICATION_CONTRACTS]; type CQRSContract = (typeof CQRS_CONTRACTS)[keyof typeof CQRS_CONTRACTS]; type UseCaseContract = (typeof USE_CASE_CONTRACTS)[keyof typeof USE_CASE_CONTRACTS]; /** * NavigationHints Interface System * * Defines AI-native navigation patterns for MCP (Model Context Protocol) servers. * Standardizes how AI agents discover and navigate between related tools and contexts. * * Design Principles: * - AI-native: Designed for LLM consumption and understanding * - Extensible: Easy to add new navigation patterns * - Cross-MCP: Supports navigation between different MCP servers * - Context-aware: Includes workflow and git state information */ /** * Operation types for workflow context * Standardized across all MCP servers */ type OperationType = 'incident' | 'maintenance' | 'discovery' | 'monitoring' | 'development' | 'planning'; /** * Severity levels for prioritization * Consistent across all domains */ type SeverityLevel = 'low' | 'medium' | 'high' | 'critical'; /** * MCP server identifiers * Canonical list of all MCP servers in the ecosystem */ type McpServerId = 'mcp__devops-mcp__' | 'mcp__gtd-mcp__' | 'mcp__party-mcp__' | 'mcp__ddd-mcp__' | 'mcp__frontend-dev__' | 'mcp__backend-dev__'; /** * Domain contexts supported across the platform */ type DomainContext = 'gtd' | 'party_management' | 'devops' | 'ddd_modeling' | 'frontend_dev' | 'backend_dev' | 'infrastructure' | 'coordination'; /** * Workflow phases for development and operational work */ type WorkflowPhase = 'planning' | 'analysis' | 'design' | 'implementation' | 'testing' | 'deployment' | 'monitoring' | 'maintenance' | 'incident_response'; /** * Reference to a tool within the same MCP server */ interface ToolReference { /** Name of the tool (e.g., 'create_person', 'health_check') */ toolName: string; /** Human-readable description of what this tool does */ description: string; /** When this tool would be relevant (e.g., 'after_creation', 'for_validation') */ relevanceContext?: string; /** Suggested parameters based on current context */ suggestedParams?: Record<string, unknown>; } /** * Reference to tools in other MCP servers */ interface CrossMcpReference { /** MCP server name from the canonical registry */ mcpServer: McpServerId; /** Tool name within that MCP server */ toolName: string; /** Why this cross-MCP tool is relevant */ relationshipDescription: string; /** Expected workflow integration */ integrationPattern?: 'sequential' | 'parallel' | 'conditional' | 'fallback'; } /** * Complex context handoff for cross-MCP workflows * Enables seamless transitions between different MCP servers with pre-populated data */ interface ContextHandoff { /** Target MCP server */ mcp: string; /** Specific tool to invoke (optional) */ tool?: string; /** Recommended action for the user */ suggested_action: string; /** Use case scenario description */ scenario: string; /** Pre-populated parameters for the target tool */ pre_populated: Record<string, unknown>; /** Workflow context for intelligent coordination */ workflow_context: { /** Type of operation being performed */ operation_type: OperationType; /** Severity or priority level */ severity: SeverityLevel; /** Domain-specific context information */ service_context?: Record<string, unknown>; domain_context?: Record<string, unknown>; user_context?: Record<string, unknown>; project_context?: Record<string, unknown>; }; } /** * Git-aware navigation hints for repository context */ interface GitNavigationHint { /** Type of git-related hint */ type: 'branch_switch' | 'commit_needed' | 'merge_conflict' | 'submodule_update' | 'status_check'; /** Human-readable message about git state */ message: string; /** Suggested git commands to resolve */ suggestedCommands?: string[]; /** Files or paths relevant to this hint */ affectedPaths?: string[]; } /** * Contextual information about current workflow state */ interface ContextualInformation { /** Current phase of work */ workflowPhase?: WorkflowPhase; /** Domain context - which bounded context or domain this relates to */ domainContext?: DomainContext; /** User's current goal or objective */ currentObjective?: string; /** Constraints or limitations to be aware of */ constraints?: string[]; /** Resources or dependencies that are available */ availableResources?: string[]; /** * Specific bounded context information * Domain-specific context that varies by MCP server */ boundedContextInfo?: { /** GTD-specific context */ gtd?: { current_area_of_focus?: string; active_projects?: string[]; inbox_items_count?: number; next_actions_due?: number; }; /** Party management context */ party?: { active_organization?: string; current_person_context?: string; team_members_involved?: string[]; }; /** DevOps context */ devops?: { affected_services?: string[]; system_health_status?: string; ongoing_incidents?: number; maintenance_windows?: string[]; }; /** DDD modeling context */ ddd?: { current_domain?: string; bounded_contexts_in_focus?: string[]; aggregates_being_designed?: string[]; }; }; } /** * Main NavigationHints interface * Provides comprehensive navigation guidance for AI agents */ interface NavigationHints { /** Immediate next steps the AI should consider */ next_steps: string[]; /** Related tools within the same MCP server */ related_tools: ToolReference[]; /** Tools in other MCP servers that might be relevant */ cross_mcp: CrossMcpReference[]; /** Git repository state and recommendations */ git_aware: GitNavigationHint[]; /** Current workflow and domain context */ context: ContextualInformation; /** * Complex context handoffs for seamless cross-MCP workflows * Enables intelligent coordination between different MCP servers */ context_handoffs?: Record<string, ContextHandoff>; /** Optional metadata for advanced navigation */ metadata?: { /** Timestamp when hints were generated */ generated_at?: string; /** Confidence level in the suggestions (0-1) */ confidence?: number; /** Source of the navigation hints */ source?: string; /** Version of the navigation system */ version?: string; }; } /** * Generic wrapper that adds navigation hints to any MCP response * Enables consistent navigation patterns across all MCP tools */ interface McpResponseWithNavigation<T> { /** The original response data */ data: T; /** Navigation hints for AI consumption */ navigation: NavigationHints; /** Optional success indicator */ success?: boolean; /** Optional error information */ error?: { code: string; message: string; details?: unknown; }; } /** * Partial navigation hints for scenarios where only some navigation info is available */ type PartialNavigationHints = Partial<NavigationHints>; /** * Navigation hint builder for fluent API construction */ interface NavigationHintsBuilder { addNextStep(step: string): NavigationHintsBuilder; addRelatedTool(tool: ToolReference): NavigationHintsBuilder; addCrossMcpTool(reference: CrossMcpReference): NavigationHintsBuilder; addGitHint(hint: GitNavigationHint): NavigationHintsBuilder; setContext(context: ContextualInformation): NavigationHintsBuilder; addContextHandoff(key: string, handoff: ContextHandoff): NavigationHintsBuilder; setMetadata(metadata: NavigationHints['metadata']): NavigationHintsBuilder; build(): NavigationHints; } /** * Factory function type for creating navigation hints */ type NavigationHintsFactory = (context?: Partial<ContextualInformation>) => NavigationHints; /** * Type for navigation hint processors that can enhance or filter hints */ type NavigationHintsProcessor = (hints: NavigationHints, context?: unknown) => NavigationHints; /** * Context handoff factory for common scenarios * Provides pre-built handoff patterns for typical cross-MCP workflows */ interface ContextHandoffFactory { createIncidentHandoff(targetMcp: McpServerId, severity: SeverityLevel, context: Record<string, unknown>): ContextHandoff; createMaintenanceHandoff(targetMcp: McpServerId, maintenanceType: string, context: Record<string, unknown>): ContextHandoff; createDiscoveryHandoff(targetMcp: McpServerId, discoveryGoal: string, context: Record<string, unknown>): ContextHandoff; createDevelopmentHandoff(targetMcp: McpServerId, developmentPhase: WorkflowPhase, context: Record<string, unknown>): ContextHandoff; createPlanningHandoff(targetMcp: McpServerId, planningScope: string, context: Record<string, unknown>): ContextHandoff; } /** * Semantic Navigation Registry Interfaces * * Defines semantic navigation patterns that leverage domain knowledge to provide * intelligent, context-aware navigation hints across MCP servers. * * Design Principles: * - Domain-agnostic: Works for any domain (GTD, Party, DevOps, DDD, etc.) * - Extensible: Domains can add their specific semantic patterns * - Type-safe: Leverages TypeScript for compile-time validation * - Minimal: Simple to implement and understand */ /** * Semantic relationship types between entities/concepts * Standardized across all domains */ type SemanticRelationType = 'contains' | 'belongs_to' | 'relates_to' | 'depends_on' | 'triggers' | 'completes' | 'blocks' | 'enables' | 'implements' | 'extends'; /** * Context sensitivity levels for semantic hints * Determines how context-aware the suggestions should be */ type ContextSensitivity = 'low' | 'medium' | 'high' | 'adaptive'; /** * Defines relationships between entities in entity-based domains * Used by domains like Party Management, DDD Modeling */ interface IEntityRelationship { /** Source entity type (e.g., 'person', 'organization', 'aggregate') */ sourceEntityType: string; /** Target entity type that relates to the source */ targetEntityType: string; /** Type of semantic relationship */ relationshipType: SemanticRelationType; /** Human-readable description of the relationship */ description: string; /** Navigation actions available for this relationship */ availableActions: { /** Action name (e.g., 'view_members', 'assign_role') */ action: string; /** Tool that implements this action */ toolName: string; /** When this action would be relevant */ relevanceContext?: string; }[]; /** Cardinality of the relationship (optional) */ cardinality?: 'one-to-one' | 'one-to-many' | 'many-to-many'; } /** * Defines workflow-based navigation for process-oriented domains * Used by domains like GTD, DevOps Operations, Development Workflows */ interface IWorkflowDefinition { /** Workflow identifier (e.g., 'gtd_capture_clarify', 'incident_response') */ workflowId: string; /** Human-readable workflow name */ name: string; /** Workflow steps in order */ steps: { /** Step identifier */ stepId: string; /** Step description */ description: string; /** Tools that can execute this step */ tools: string[]; /** Conditions to proceed to next step (optional) */ completionCriteria?: string[]; /** Next possible steps */ nextSteps?: string[]; }[]; /** Workflow triggers - what initiates this workflow */ triggers: { /** Event or condition that starts the workflow */ trigger: string; /** Context in which this trigger applies */ context?: Record<string, unknown>; }[]; /** Expected outcomes when workflow completes */ outcomes: string[]; } /** * What each domain provides for semantic navigation * This is what domains register in the semantic registry */ interface IDomainSemantics { /** Domain identifier from the canonical list */ domainId: DomainContext; /** MCP server that implements this domain */ mcpServerId: McpServerId; /** Entity relationships this domain understands */ entityRelationships?: IEntityRelationship[]; /** Workflows this domain implements */ workflows?: IWorkflowDefinition[]; /** Domain-specific semantic patterns */ customSemantics?: { /** Pattern identifier */ patternId: string; /** Pattern description */ description: string; /** Context where this pattern applies */ applicableContext: Record<string, unknown>; /** Navigation hints this pattern provides */ navigationHints: Partial<NavigationHints>; }[]; /** Confidence level in these semantic definitions (0-1) */ confidence?: number; /** Last updated timestamp */ lastUpdated?: string; } /** * Main registry interface for domain semantics * Central registry that aggregates semantic knowledge from all domains */ interface ISemanticNavigationRegistry { /** * Register domain semantics * Domains call this to register their semantic patterns */ registerDomainSemantics(semantics: IDomainSemantics): Promise<void>; /** * Get semantics for a specific domain */ getDomainSemantics(domainId: DomainContext): Promise<IDomainSemantics | null>; /** * Get all registered domain semantics */ getAllDomainSemantics(): Promise<IDomainSemantics[]>; /** * Find related entities across domains * Returns semantic relationships that span multiple domains */ findCrossDomainRelationships(entityType: string, entityId: string): Promise<{ domain: DomainContext; relationships: IEntityRelationship[]; }[]>; /** * Get applicable workflows for current context * Returns workflows that could be relevant given the current state */ getApplicableWorkflows(context: Record<string, unknown>): Promise<{ domain: DomainContext; workflows: IWorkflowDefinition[]; relevanceScore: number; }[]>; /** * Generate semantic navigation hints * Core method that produces enhanced navigation hints using domain semantics */ generateSemanticHints(currentContext: Record<string, unknown>, sensitivity?: ContextSensitivity): Promise<SemanticNavigationHints>; } /** * Enhanced NavigationHints with semantic information * Extends the base NavigationHints with domain-aware semantic intelligence */ interface SemanticNavigationHints extends NavigationHints { /** Semantic relationships relevant to current context */ semantic_relationships: { /** Relationship definition */ relationship: IEntityRelationship; /** Domain that provides this relationship */ sourceDomain: DomainContext; /** Current relevance score (0-1) */ relevanceScore: number; /** Suggested navigation actions */ suggestedActions: string[]; }[]; /** Applicable workflows for current context */ applicable_workflows: { /** Workflow definition */ workflow: IWorkflowDefinition; /** Domain that provides this workflow */ sourceDomain: DomainContext; /** Current step in workflow (if already in progress) */ currentStep?: string; /** Suggested next actions */ suggestedNextActions: string[]; /** Confidence this workflow applies (0-1) */ applicabilityScore: number; }[]; /** Cross-domain insights */ cross_domain_insights: { /** Insight description */ insight: string; /** Domains involved in this insight */ involvedDomains: DomainContext[]; /** Suggested actions to leverage this insight */ actionableSteps: string[]; /** Confidence level (0-1) */ confidence: number; }[]; /** Semantic metadata */ semantic_metadata: { /** Context sensitivity level used */ contextSensitivity: ContextSensitivity; /** Domains consulted for these hints */ consultedDomains: DomainContext[]; /** Processing time for semantic analysis */ processingTimeMs?: number; /** Version of semantic registry used */ registryVersion?: string; }; } /** * Registry configuration options */ interface SemanticRegistryOptions { /** How often to refresh domain semantics */ refreshIntervalMs?: number; /** Default context sensitivity */ defaultSensitivity?: ContextSensitivity; /** Maximum number of relationships to include in hints */ maxRelationships?: number; /** Maximum number of workflows to suggest */ maxWorkflows?: number; /** Enable cross-domain insights */ enableCrossDomainInsights?: boolean; } /** * Semantic hint generation options */ interface SemanticHintOptions { /** Context sensitivity level */ sensitivity?: ContextSensitivity; /** Specific domains to consult (default: all) */ consultDomains?: DomainContext[]; /** Include cross-domain insights */ includeCrossDomainInsights?: boolean; /** Maximum processing time before fallback */ maxProcessingTimeMs?: number; } /** * Factory function for creating semantic navigation hints */ type SemanticNavigationHintsFactory = (context: Record<string, unknown>, options?: SemanticHintOptions) => Promise<SemanticNavigationHints>; /** * MCP Semantic Startup Enforcer * * MANDATORY startup protocol for all MCP servers to ensure they load and understand * their domain's semantic navigation before accepting any requests. * * This enforces the AGENT-STARTUP-PROTOCOL.md requirements with specific focus on * semantic navigation to prevent agents from "taking shortcuts" and missing context. * * @author Technical Coordinator & Derick * @since 2025-08-02 */ /** * Startup validation result */ interface SemanticStartupResult { success: boolean; domainId: string; entityRelationships: number; workflows: number; customSemantics: number; errors: string[]; warnings: string[]; } /** * Domain boundary information from DOMAIN-BOUNDARY-MAP.md */ interface DomainBoundary { domainId: string; domainRef: string; packageName: string; services: string[]; boundedContexts: string[]; publishedLanguage: string[]; database?: string; } /** * Enforces semantic navigation loading at MCP server startup */ declare class MCPSemanticStartupEnforcer { private domainId; private packageName; private semantics?; private domainBoundary?; private startupResult; constructor(domainId: string, packageName: string); /** * Execute mandatory startup sequence * Throws on critical errors, preventing server startup */ enforceStartup(): Promise<SemanticStartupResult>; /** * Load and parse Domain Boundary Map */ private loadDomainBoundaryMap; /** * Parse domain boundary map markdown to extract domain info */ private parseDomainBoundaryMap; /** * Load semantic navigation from domain package */ private loadSemanticNavigation; /** * Try to load semantics from various possible locations */ private tryLoadSemantics; /** * Create minimal semantic navigation when none exists */ private createMinimalSemantics; /** * Validate the MCP server understands its semantic context */ private validateSemanticUnderstanding; /** * Display semantic navigation summary */ private displaySemanticSummary; /** * Get loaded semantic navigation for use by MCP server */ getSemantics(): IDomainSemantics | undefined; /** * Get domain boundary information */ getDomainBoundary(): DomainBoundary | undefined; } /** * Factory function for easy creation */ declare function createSemanticEnforcer(domainId: string, packageName: string): MCPSemanticStartupEnforcer; /** * Standard health check response structure for all MCP servers * Eliminates duplication while allowing domain-specific customization */ interface StandardHealthResponse { status: 'ok' | 'error' | 'degraded'; service: string; version?: string; timestamp: string; checks: Record<string, any>; metrics?: Record<string, any>; } /** * Health check response with navigation hints */ interface HealthCheckWithNavigation { content: StandardHealthResponse; _navigation: NavigationHints; } /** * Domain-specific health details */ interface DomainHealthDetails { [key: string]: any; } /** * Utility functions for creating standard health responses */ declare class HealthCheckUtils { /** * Create standard health response structure */ static createResponse(serviceName: string, version: string, domainChecks: Record<string, any>, domainDetails?: DomainHealthDetails, metrics?: Record<string, any>): StandardHealthResponse; /** * Create error response */ static createErrorResponse(serviceName: string, error: any): StandardHealthResponse; /** * Standard metrics collection */ static collectStandardMetrics(): Record<string, any>; } /** * Navigation hint patterns for health checks */ declare class HealthNavigationPatterns { /** * Common cross-MCP health navigation hints */ static getSystemHealthHints(): Array<{ toolName: string; description: string; relevanceContext: string; }>; /** * Service recovery navigation hints */ static getRecoveryHints(serviceName: string): Array<{ toolName: string; description: string; }>; } /** * Shared Cross-Cutting Contracts * * Defines dependency injection symbols for cross-cutting concerns * that span multiple layers and bounded contexts. */ /** * Navigation and AI-native discovery contracts * Standardizes navigation patterns across MCP servers */ declare const NAVIGATION_CONTRACTS: { readonly NAVIGATION_HINTS_PROVIDER: symbol; readonly NAVIGATION_HINTS_BUILDER: symbol; readonly NAVIGATION_HINTS_FACTORY: symbol; readonly CROSS_MCP_NAVIGATOR: symbol; readonly MCP_TOOL_REGISTRY: symbol; readonly WORKFLOW_CONTEXT_PROVIDER: symbol; readonly GIT_CONTEXT_PROVIDER: symbol; readonly NAVIGATION_PROCESSOR: symbol; readonly NAVIGATION_FILTER: symbol; readonly SEMANTIC_NAVIGATION_REGISTRY: symbol; readonly SEMANTIC_HINTS_FACTORY: symbol; readonly DOMAIN_SEMANTICS_PROVIDER: symbol; }; /** * Logging and observability contracts * Used across all layers for consistent logging */ declare const LOGGING_CONTRACTS: { readonly LOGGER: symbol; readonly BOUNDED_CONTEXT_LOGGER: symbol; readonly LAYER_LOGGER: symbol; readonly PERFORMANCE_MONITOR: symbol; readonly METRICS_COLLECTOR: symbol; readonly HEALTH_CHECK_SERVICE: symbol; readonly DISK_HEALTH_MONITOR: symbol; }; /** * Security and authorization contracts * Cross-cutting security concerns */ declare const SECURITY_CONTRACTS: { readonly AUTHENTICATION_SERVICE: symbol; readonly TOKEN_VALIDATOR: symbol; readonly AUTHORIZATION_SERVICE: symbol; readonly PERMISSION_CHECKER: symbol; readonly AUDIT_LOGGER: symbol; readonly SECURITY_EVENT_PUBLISHER: symbol; }; /** * Configuration and environment contracts * Centralized configuration management */ declare const CONFIGURATION_CONTRACTS: { readonly SERVER_CONFIG: symbol; readonly DATABASE_CONFIG: symbol; readonly DEVELOPMENT_CONFIG: symbol; readonly PRODUCTION_CONFIG: symbol; readonly FEATURE_FLAG_SERVICE: symbol; readonly ENVIRONMENT_DETECTOR: symbol; }; type NavigationContract = (typeof NAVIGATION_CONTRACTS)[keyof typeof NAVIGATION_CONTRACTS]; type LoggingContract = (typeof LOGGING_CONTRACTS)[keyof typeof LOGGING_CONTRACTS]; type SecurityContract = (typeof SECURITY_CONTRACTS)[keyof typeof SECURITY_CONTRACTS]; type ConfigurationContract = (typeof CONFIGURATION_CONTRACTS)[keyof typeof CONFIGURATION_CONTRACTS]; /** * Contract Registry - Single Source of Truth * * Central registry that aggregates all DI contracts across layers. * This provides a single import point for all dependency injection symbols, * ensuring consistency and preventing symbol duplication. * * Usage: * ```typescript * import { CONTRACTS } from '@swoft/platform-contracts'; * * @inject(CONTRACTS.INFRASTRUCTURE.MONGO_CLIENT) * @inject(CONTRACTS.DOMAIN.SCHEMA_REPOSITORY) * @inject(CONTRACTS.APPLICATION.CAS_SERVICE) * ``` */ /** * The CONTRACTS registry - single source of truth for all DI symbols * * Organized by architectural layer following DDD principles: * - INFRASTRUCTURE: External adapters (databases, APIs, file systems) * - DOMAIN: Core business logic ports (repositories, domain services) * - APPLICATION: Use cases and application services * - SHARED: Cross-cutting concerns (logging, security, config) */ declare const CONTRACTS: { readonly INFRASTRUCTURE: { readonly MONGO_CLIENT: symbol; readonly DATABASE_NAME: symbol; readonly MONGO_CONNECTION_STRING: symbol; readonly CAS_STORAGE_PORT: symbol; readonly DISK_REGISTRY_PORT: symbol; readonly DISK_ADAPTER_RESOLVER: symbol; readonly S3_CLIENT: symbol; readonly SECRET_MANAGER: symbol; }; readonly DOMAIN: { readonly REPOSITORIES: { readonly SCHEMA_REPOSITORY: symbol; readonly BUSINESS_ACTION_REPOSITORY: symbol; readonly DOCUMENTATION_REPOSITORY: symbol; readonly ATOMIC_TASK_REPOSITORY: symbol; readonly HANDOFF_REPOSITORY: symbol; readonly MESSAGE_REPOSITORY: symbol; }; readonly SERVICES: { readonly CONTENT_DISCOVERY_SERVICE: symbol; readonly RELATIONSHIP_DISCOVERY_SERVICE: symbol; readonly TASK_ORCHESTRATION_SERVICE: symbol; readonly BUSINESS_ACTION_ORCHESTRATOR: symbol; }; }; readonly APPLICATION: { readonly SERVICES: { readonly CAS_SERVICE: symbol; readonly CONTRACT_DISCOVERY_SERVICE: symbol; readonly SCHEMA_APPLICATION_SERVICE: symbol; readonly DOCUMENTATION_APPLICATION_SERVICE: symbol; readonly SERVICE_MANAGER: symbol; readonly SERVICE_REGISTRY: symbol; readonly TASK_ORCHESTRATOR: symbol; readonly SEEDER_MANAGER: symbol; readonly VALIDATION_SERVICE: symbol; }; readonly CQRS: { readonly COMMAND_BUS: symbol; readonly COMMAND_HANDLER_REGISTRY: symbol; readonly QUERY_BUS: symbol; readonly QUERY_HANDLER_REGISTRY: symbol; readonly EVENT_BUS: symbol; readonly EVENT_HANDLER_REGISTRY: symbol; }; readonly USE_CASES: { readonly START_SERVICE_USE_CASE: symbol; readonly STOP_SERVICE_USE_CASE: symbol; readonly LIST_SERVICES_USE_CASE: symbol; readonly CREATE_DOCUMENTATION_USE_CASE: symbol; readonly UPDATE_DOCUMENTATION_USE_CASE: symbol; readonly PUBLISH_DOCUMENTATION_USE_CASE: symbol; }; }; readonly SHARED: { readonly LOGGING: { readonly LOGGER: symbol; readonly BOUNDED_CONTEXT_LOGGER: symbol; readonly LAYER_LOGGER: symbol; readonly PERFORMANCE_MONITOR: symbol; readonly METRICS_COLLECTOR: symbol; readonly HEALTH_CHECK_SERVICE: symbol; readonly DISK_HEALTH_MONITOR: symbol; }; readonly SECURITY: { readonly AUTHENTICATION_SERVICE: symbol; readonly TOKEN_VALIDATOR: symbol; readonly AUTHORIZATION_SERVICE: symbol; readonly PERMISSION_CHECKER: symbol; readonly AUDIT_LOGGER: symbol; readonly SECURITY_EVENT_PUBLISHER: symbol; }; readonly CONFIGURATION: { readonly SERVER_CONFIG: symbol; readonly DATABASE_CONFIG: symbol; readonly DEVELOPMENT_CONFIG: symbol; readonly PRODUCTION_CONFIG: symbol; readonly FEATURE_FLAG_SERVICE: symbol; readonly ENVIRONMENT_DETECTOR: symbol; }; }; }; /** * Legacy exports for backward compatibility during migration * TODO: Remove after all packages are migrated to CONTRACTS registry * * @deprecated Use CONTRACTS.INFRASTRUCTURE.* instead */ declare const DI_MONGO_CLIENT: symbol; declare const DI_DATABASE_NAME: symbol; declare const DI_MONGO_CONNECTION_STRING: symbol; /** * @deprecated Use CONTRACTS.DOMAIN.REPOSITORIES.* instead */ declare const DI_SCHEMA_REPOSITORY: symbol; declare const DI_DOCUMENTATION_REPOSITORY: symbol; /** * @deprecated Use CONTRACTS.APPLICATION.SERVICES.* instead */ declare const DI_CAS_SERVICE: symbol; declare const DI_SERVICE_MANAGER: symbol; /** * Extract all contract symbols as a union type * Useful for type-safe container registration */ type AllContracts = (typeof CONTRACTS.INFRASTRUCTURE)[keyof typeof CONTRACTS.INFRASTRUCTURE] | (typeof CONTRACTS.DOMAIN.REPOSITORIES)[keyof typeof CONTRACTS.DOMAIN.REPOSITORIES] | (typeof CONTRACTS.DOMAIN.SERVICES)[keyof typeof CONTRACTS.DOMAIN.SERVICES] | (typeof CONTRACTS.APPLICATION.SERVICES)[keyof typeof CONTRACTS.APPLICATION.SERVICES] | (typeof CONTRACTS.APPLICATION.CQRS)[keyof typeof CONTRACTS.APPLICATION.CQRS] | (typeof CONTRACTS.APPLICATION.USE_CASES)[keyof typeof CONTRACTS.APPLICATION.USE_CASES] | (typeof CONTRACTS.SHARED.LOGGING)[keyof typeof CONTRACTS.SHARED.LOGGING] | (typeof CONTRACTS.SHARED.SECURITY)[keyof typeof CONTRACTS.SHARED.SECURITY] | (typeof CONTRACTS.SHARED.CONFIGURATION)[keyof typeof CONTRACTS.SHARED.CONFIGURATION]; /** * Contract metadata for documentation and tooling */ declare const CONTRACT_METADATA: { readonly version: "1.0.0"; readonly totalContracts: number; readonly layers: readonly ["INFRASTRUCTURE", "DOMAIN", "APPLICATION", "SHARED"]; readonly description: "DDD-compliant dependency injection contracts for Swoft platform"; }; export { APPLICATION_CONTRACTS, type AllContracts, type ApplicationContract, CONFIGURATION_CONTRACTS, CONTRACTS, CONTRACT_METADATA, type CQRSContract, CQRS_CONTRACTS, type ConfigurationContract, type ContextHandoff, type ContextHandoffFactory, type ContextSensitivity, type ContextualInformation, type CrossMcpReference, DI_CAS_SERVICE, DI_DATABASE_NAME, DI_DOCUMENTATION_REPOSITORY, DI_MONGO_CLIENT, DI_MONGO_CONNECTION_STRING, DI_SCHEMA_REPOSITORY, DI_SERVICE_MANAGER, DOMAIN_CONTRACTS, DOMAIN_SERVICE_CONTRACTS, type DomainContext, type DomainContract, type DomainHealthDetails, type DomainServiceContract, type GitNavigationHint, HealthCheckUtils, type HealthCheckWithNavigation, HealthNavigationPatterns, type IDomainSemantics, type IEntityRelationship, INFRASTRUCTURE_CONTRACTS, type ISemanticNavigationRegistry, type IWorkflowDefinition, type InfrastructureContract, LOGGING_CONTRACTS, type LoggingContract, MCPSemanticStartupEnforcer, type McpResponseWithNavigation, type McpServerId, NAVIGATION_CONTRACTS, type NavigationContract, type NavigationHints, type NavigationHintsBuilder, type NavigationHintsFactory, type NavigationHintsProcessor, type OperationType, type PartialNavigationHints, SECURITY_CONTRACTS, type SecurityContract, type SemanticHintOptions, type SemanticNavigationHints, type SemanticNavigationHintsFactory, type SemanticRegistryOptions, type SemanticRelationType, type SemanticStartupResult, type SeverityLevel, type StandardHealthResponse, type ToolReference, USE_CASE_CONTRACTS, type UseCaseContract, type WorkflowPhase, createSemanticEnforcer };