/**
 * Centralized Kafka topic definitions.
 * All services reference these constants for topic names.
 * Topic naming convention: genex.<domain>.<event-type>
 */
export const KAFKA_TOPICS = {
  // User domain events
  USER_REGISTERED: 'genex.user.registered',
  USER_KYC_SUBMITTED: 'genex.user.kyc-submitted',
  USER_KYC_APPROVED: 'genex.user.kyc-approved',
  USER_KYC_REJECTED: 'genex.user.kyc-rejected',

  // Wallet domain events
  WALLET_DEPOSIT: 'genex.wallet.deposit',
  WALLET_WITHDRAWAL: 'genex.wallet.withdrawal',
  WALLET_TRANSFER: 'genex.wallet.transfer',
  WALLET_BALANCE_CHANGED: 'genex.wallet.balance-changed',

  // Coupon domain events
  COUPON_CREATED: 'genex.coupon.created',
  COUPON_UPDATED: 'genex.coupon.updated',
  COUPON_PURCHASED: 'genex.coupon.purchased',
  COUPON_REDEEMED: 'genex.coupon.redeemed',
  COUPON_TRANSFERRED: 'genex.coupon.transferred',
  COUPON_EXPIRED: 'genex.coupon.expired',

  // Trading domain events
  ORDER_PLACED: 'genex.trade.order-placed',
  ORDER_CANCELLED: 'genex.trade.order-cancelled',
  TRADE_MATCHED: 'genex.trade.matched',
  TRADE_SETTLED: 'genex.trade.settled',
  ORDERBOOK_SNAPSHOT: 'genex.trade.orderbook-snapshot',

  // Clearing domain events
  SETTLEMENT_COMPLETED: 'genex.clearing.settlement-completed',
  REFUND_INITIATED: 'genex.clearing.refund-initiated',
  REFUND_COMPLETED: 'genex.clearing.refund-completed',
  BREAKAGE_CALCULATED: 'genex.clearing.breakage-calculated',
  JOURNAL_ENTRY_CREATED: 'genex.clearing.journal-entry',

  // Compliance domain events
  AML_ALERT_CREATED: 'genex.compliance.aml-alert',
  OFAC_SCREENING_COMPLETED: 'genex.compliance.ofac-screening',
  TRAVEL_RULE_SENT: 'genex.compliance.travel-rule',
  SAR_REPORT_FILED: 'genex.compliance.sar-filed',

  // Notification domain events
  NOTIFICATION_SEND: 'genex.notification.send',
  NOTIFICATION_DELIVERED: 'genex.notification.delivered',

  // Issuer domain events
  ISSUER_REGISTERED: 'genex.issuer.registered',
  ISSUER_APPROVED: 'genex.issuer.approved',
  ISSUER_STORE_CREATED: 'genex.issuer.store-created',

  // Chain (blockchain) domain events
  CHAIN_TX_SUBMITTED: 'genex.chain.tx-submitted',
  CHAIN_TX_CONFIRMED: 'genex.chain.tx-confirmed',
  CHAIN_BLOCK_INDEXED: 'genex.chain.block-indexed',

  // Dead letter topics
  DLQ_USER: 'genex.dlq.user',
  DLQ_TRADE: 'genex.dlq.trade',
  DLQ_CLEARING: 'genex.dlq.clearing',
  DLQ_COMPLIANCE: 'genex.dlq.compliance',
} as const;

export type KafkaTopic = (typeof KAFKA_TOPICS)[keyof typeof KAFKA_TOPICS];

/**
 * Consumer group IDs for each service.
 * Each service has its own consumer group for independent offset tracking.
 */
export const CONSUMER_GROUPS = {
  USER_SERVICE: 'genex-user-service',
  ISSUER_SERVICE: 'genex-issuer-service',
  TRADING_SERVICE: 'genex-trading-service',
  CLEARING_SERVICE: 'genex-clearing-service',
  COMPLIANCE_SERVICE: 'genex-compliance-service',
  NOTIFICATION_SERVICE: 'genex-notification-service',
  CHAIN_INDEXER: 'genex-chain-indexer',
} as const;
