// import { UsersEntity } from 'src/entities/Users.entity';

/**
 * ResetPassEvent - Domain event for password reset completion operations
 *
 * This event class represents the completion of a password reset process
 * in the application's event-driven architecture. It encapsulates the data
 * needed to process post-reset operations after a user has successfully
 * changed their password.
 *
 * Domain events like this enable:
 * - Decoupling of reset completion logic from side effects
 * - Asynchronous processing of post-reset notifications
 * - Multiple handlers for the same event (confirmation emails, security logging)
 * - Scalable architecture through event-driven patterns
 *
 * Typical use cases:
 * 1. Send password change confirmation email
 * 2. Send security alert about password change
 * 3. Log password change for security monitoring
 * 4. Invalidate old sessions/tokens for security
 * 5. Update user's security audit trail
 * 6. Trigger fraud detection checks
 *
 * @example
 * // Creating and emitting the event
 * const resetPassEvent = new ResetPassEvent(resetToken, 'dm');
 * this.eventEmitter.emit('password.reset.complete', resetPassEvent);
 *
 * @example
 * // Handling the event in a listener
 * @OnEvent('password.reset.complete')
 * async handleResetPassword(event: ResetPassEvent) {
 *   // Send confirmation email
 *   await this.emailService.sendPasswordChangeConfirmation(event.token);
 *
 *   // Log security event
 *   await this.securityService.logPasswordChange(event.token);
 *
 *   // Invalidate old sessions
 *   await this.sessionService.invalidateUserSessions(event.token);
 * }
 */
export class ResetPassEvent {
  /**
   * Creates a new ResetPassEvent instance
   *
   * @param token - Password reset verification token or user identifier
   * @param flag - System flag indicating reset method or configuration
   */
  constructor(
    /**
     * Optional: User entity reference
     * Consider adding this back when you need to pass user data to handlers
     * public user: UsersEntity | undefined | null,
     */

    /**
     * Password reset token or user identifier
     *
     * This typically contains:
     * - Reset token: The verification token used in the reset process
     * - User ID: Identifier to look up the user who changed their password
     * - Session token: Token to invalidate old sessions
     * - null: If the reset process doesn't require token tracking
     *
     * Security considerations:
     * - Tokens should be invalidated after use
     * - Avoid logging sensitive token data
     * - Use token to identify user without exposing credentials
     *
     * @note Making this nullable allows flexibility but reduces type safety
     *
     * @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." // JWT reset token
     * @example "user_12345" // User identifier
     * @example null // No token needed for this reset flow
     */
    public token: string | null,

    /**
     * System flag indicating reset configuration
     *
     * Determines which password reset workflow or system was used.
     * Can affect:
     * - Email template selection
     * - Notification channels
     * - Logging format
     * - Security policy application
     *
     * Common values:
     * - 'dm': Direct method (standard password reset flow)
     * - 'guglu': Alternative method (legacy system, partner integration, etc.)
     *
     * @note Consider using an enum for type safety:
     *   enum ResetFlag { DM = 'dm', GUGLU = 'guglu' }
     *
     * @example "dm"
     * @example "guglu"
     */
    public flag: string | null,
  ) {}
}
