Interface Documentation
Overview
This document provides comprehensive documentation of all TypeScript interfaces, DTOs, enums, and type definitions used in the Customer Management module. These interfaces ensure type safety, establish clear contracts between layers, and facilitate integration with other modules in the Bee O'clock ecosystem.
Core Interfaces
Customer Entity Interface
interface ICustomer extends IBase {
firstName?: string; // Customer first name
lastName?: string; // Customer last name
phone?: string; // Normalized phone number (numbers only)
email?: string; // Validated email address
note?: string; // Internal business notes
customerType?: CustomerTypeEnum; // Customer classification type
createdAt?: string; // Creation timestamp (ISO string)
updatedAt?: string; // Last update timestamp (ISO string)
}Base Entity Interface
interface IBase {
_id?: string; // MongoDB ObjectId as string
state?: string; // Entity state (active, inactive, deleted)
stateHistory?: IStateHistoryEntry[]; // State change audit trail
_version?: string; // Optimistic locking version
}Data Transfer Objects (DTOs)
CustomerDto
Primary DTO for customer data transfer across API boundaries.
CustomerPaginationDto
DTO for customer pagination parameters.
CustomerFilterDto
DTO for advanced customer filtering options.
Order Integration DTOs
AttendantDto
DTO representing a customer as an attendee in order services.
PublicAttendantDto
DTO for customer information in public order creation (client-facing).
Enumerations
CustomerTypeEnum
Defines different types of customers in the system.
CustomerStateEnum
Defines possible states for customer entities.
Use Case Interfaces
Customer Use Case Parameters
Customer Validation Parameters
Domain Value Objects
Customer Contact Information
Customer Preferences
Command and Query Interfaces
Command Interfaces
Query Interfaces
Message Interfaces
Customer Event Messages
Cache Interfaces
Cache Key Definitions
Cache Strategy Interfaces
Repository Filter Interfaces
Customer Repository Filters
Customer Search Criteria
Context Interfaces
Tenant Actor Context
Customer Operation Context
Validation and Error Interfaces
Customer Validation Result
Exception Interfaces
Integration Interfaces
Order Integration
Payment Integration
Notification Integration
Mapper Interfaces
Customer Mapping Contracts
Type Utilities
Customer Type Guards
Customer Utility Types
Configuration Interfaces
Customer Module Configuration
Usage Guidelines
DTO Validation
Always use class-validator decorators for automatic validation
Apply @Expose() decorators for proper serialization control
Use @Type() decorators for nested object transformation
Implement proper error handling for validation failures
Type Safety
Use TypeScript interfaces for compile-time type checking
Implement type guards for runtime type validation
Apply generic constraints for reusable type definitions
Use discriminated unions for type-safe polymorphism
Error Handling
Implement domain-specific exceptions with clear error codes
Provide detailed validation results with field-level errors
Use Result types for operation outcomes
Maintain error message consistency across the module
Message Contracts
Define clear event payloads for inter-service communication
Version message interfaces for backward compatibility
Include correlation IDs for request tracing
Implement idempotent message processing
Cache Keys
Use enum-defined cache keys for consistency
Include tenant context in cache key generation
Implement cache invalidation strategies for data consistency
Consider cache TTL values based on data volatility
Context Propagation
Always pass TenantActorContext for proper authorization
Include operation metadata for auditing and debugging
Maintain request correlation across service boundaries
Implement proper context validation
Interface Evolution
When modifying interfaces:
Consider backward compatibility for existing consumers
Use optional properties for new fields to maintain compatibility
Increment version numbers for breaking changes
Update validation rules consistently across DTOs
Document migration paths for interface changes
Test interface changes thoroughly across all integration points
Performance Considerations
Use selective field projection in repository interfaces
Implement efficient search interfaces with proper indexing
Consider pagination interfaces for large result sets
Design cache-friendly interfaces with appropriate granularity
Optimize serialization through proper DTO design
Security Considerations
Never expose sensitive data in public interfaces
Implement proper input validation in all DTOs
Use secure context propagation for authorization
Audit interface access for compliance requirements
Encrypt sensitive fields in persistence interfaces
Summary
The Customer Management module interfaces provide a comprehensive type-safe foundation for customer operations within the Bee O'clock ecosystem. Key aspects include:
Strongly Typed DTOs: Comprehensive data transfer objects with validation
Domain Interfaces: Clear contracts for business logic and data persistence
Integration Support: Well-defined interfaces for order and payment integration
Event-Driven Architecture: Message interfaces for asynchronous communication
Error Handling: Structured exception and validation interfaces
Performance Optimization: Cache and search interfaces for efficient operations
Security Compliance: Secure context and validation interfaces
These interfaces ensure consistency, maintainability, and reliability across the customer management domain while supporting complex business scenarios and integration requirements.
Last updated
Was this helpful?