/**
 * License Repository Port
 *
 * Interface for license persistence operations.
 */

import { License } from '../../entities/license.entity';

export const LICENSE_REPOSITORY = 'LICENSE_REPOSITORY';

export interface LicenseRepository {
  /**
   * Save a license (create or update)
   */
  save(license: License): Promise<License>;

  /**
   * Find a license by its ID
   */
  findById(id: string): Promise<License | null>;

  /**
   * Find a license by user ID
   */
  findByUserId(userId: string): Promise<License | null>;

  /**
   * Find all licenses for a subscription
   */
  findBySubscriptionId(subscriptionId: string): Promise<License[]>;

  /**
   * Find all active licenses for a subscription
   */
  findActiveBySubscriptionId(subscriptionId: string): Promise<License[]>;

  /**
   * Count active licenses for a subscription
   */
  countActiveBySubscriptionId(subscriptionId: string): Promise<number>;

  /**
   * Count active licenses for a subscription, excluding ADMIN users
   * ADMIN users have unlimited licenses and don't consume the organization's quota
   */
  countActiveBySubscriptionIdExcludingAdmins(subscriptionId: string): Promise<number>;

  /**
   * Find all active licenses for a subscription, excluding ADMIN users
   */
  findActiveBySubscriptionIdExcludingAdmins(subscriptionId: string): Promise<License[]>;

  /**
   * Delete a license
   */
  delete(id: string): Promise<void>;

  /**
   * Delete all licenses for a subscription
   */
  deleteBySubscriptionId(subscriptionId: string): Promise<void>;
}
