/**
 * Subscription Validation Coordinator Types
 *
 * Centralized type definitions for subscription validation patterns:
 * - Account mapping validation (user → whmcsClientId + sfAccountId)
 * - Product type detection (Internet vs SIM)
 * - OpportunityId resolution (from custom fields or Salesforce lookup)
 */

import type { ServiceType } from "@customer-portal/domain/subscriptions";

/**
 * Result of validating a user's account mapping.
 * Contains all external system IDs needed for subscription operations.
 */
export interface AccountMappingResult {
  /** WHMCS Client ID for billing operations */
  whmcsClientId: number;
  /** Salesforce Account ID for CRM operations */
  sfAccountId: string;
}

/**
 * Result of resolving an OpportunityId for a subscription.
 */
export interface OpportunityResolution {
  /** Salesforce Opportunity ID (if found) */
  opportunityId: string | null;
  /** Source of the OpportunityId resolution */
  source: "custom_fields" | "salesforce_lookup" | "not_found";
}

/**
 * Options for OpportunityId resolution.
 */
export interface OpportunityResolutionOptions {
  /** WHMCS subscription custom fields to check first */
  customFields?: Record<string, string> | undefined;
  /** Whether to fall back to Salesforce lookup if not in custom fields */
  fallbackToSalesforce?: boolean;
}

/**
 * Service type detection result with metadata
 */
export interface ServiceTypeResult {
  /** Detected service type */
  type: ServiceType;
  /** Product name used for detection */
  productName: string;
}

/**
 * Re-export ServiceType for convenience
 */
export type { ServiceType };
