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

  1. Always use class-validator decorators for automatic validation

  2. Apply @Expose() decorators for proper serialization control

  3. Use @Type() decorators for nested object transformation

  4. Implement proper error handling for validation failures

Type Safety

  1. Use TypeScript interfaces for compile-time type checking

  2. Implement type guards for runtime type validation

  3. Apply generic constraints for reusable type definitions

  4. Use discriminated unions for type-safe polymorphism

Error Handling

  1. Implement domain-specific exceptions with clear error codes

  2. Provide detailed validation results with field-level errors

  3. Use Result types for operation outcomes

  4. Maintain error message consistency across the module

Message Contracts

  1. Define clear event payloads for inter-service communication

  2. Version message interfaces for backward compatibility

  3. Include correlation IDs for request tracing

  4. Implement idempotent message processing

Cache Keys

  1. Use enum-defined cache keys for consistency

  2. Include tenant context in cache key generation

  3. Implement cache invalidation strategies for data consistency

  4. Consider cache TTL values based on data volatility

Context Propagation

  1. Always pass TenantActorContext for proper authorization

  2. Include operation metadata for auditing and debugging

  3. Maintain request correlation across service boundaries

  4. Implement proper context validation

Interface Evolution

When modifying interfaces:

  1. Consider backward compatibility for existing consumers

  2. Use optional properties for new fields to maintain compatibility

  3. Increment version numbers for breaking changes

  4. Update validation rules consistently across DTOs

  5. Document migration paths for interface changes

  6. Test interface changes thoroughly across all integration points

Performance Considerations

  1. Use selective field projection in repository interfaces

  2. Implement efficient search interfaces with proper indexing

  3. Consider pagination interfaces for large result sets

  4. Design cache-friendly interfaces with appropriate granularity

  5. Optimize serialization through proper DTO design

Security Considerations

  1. Never expose sensitive data in public interfaces

  2. Implement proper input validation in all DTOs

  3. Use secure context propagation for authorization

  4. Audit interface access for compliance requirements

  5. 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?