import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { QueueModule } from "@bff/infra/queue/queue.module.js";
import { SalesforceFacade } from "./facades/salesforce.facade.js";
import { SalesforceConnection } from "./services/salesforce-connection.service.js";
import { SalesforceAccountService } from "./services/salesforce-account.service.js";
import { SalesforceOrderService } from "./services/salesforce-order.service.js";
import { SalesforceCaseService } from "./services/salesforce-case.service.js";
import { SalesforceOpportunityService } from "./services/salesforce-opportunity.service.js";
import { OpportunityResolutionService } from "./services/opportunity-resolution.service.js";
import { SalesforceOrderFieldConfigModule } from "./config/salesforce-order-field-config.module.js";
import { SalesforceReadThrottleGuard } from "./guards/salesforce-read-throttle.guard.js";
import { SalesforceWriteThrottleGuard } from "./guards/salesforce-write-throttle.guard.js";
import { OpportunityQueryService } from "./services/opportunity/opportunity-query.service.js";
import { OpportunityCancellationService } from "./services/opportunity/opportunity-cancellation.service.js";
import { OpportunityMutationService } from "./services/opportunity/opportunity-mutation.service.js";
import { SalesforceErrorHandlerService } from "./services/salesforce-error-handler.service.js";
import { SalesforceSIMInventoryService } from "./services/salesforce-sim-inventory.service.js";

@Module({
  imports: [QueueModule, ConfigModule, SalesforceOrderFieldConfigModule],
  providers: [
    SalesforceErrorHandlerService,
    SalesforceConnection,
    SalesforceAccountService,
    SalesforceOrderService,
    SalesforceCaseService,
    // Opportunity decomposed services
    OpportunityQueryService,
    OpportunityCancellationService,
    OpportunityMutationService,
    // Opportunity facade (depends on decomposed services)
    SalesforceOpportunityService,
    OpportunityResolutionService,
    SalesforceSIMInventoryService,
    SalesforceFacade,
    SalesforceReadThrottleGuard,
    SalesforceWriteThrottleGuard,
  ],
  exports: [
    QueueModule,
    SalesforceErrorHandlerService,
    SalesforceFacade,
    SalesforceConnection,
    SalesforceAccountService,
    SalesforceOrderService,
    SalesforceCaseService,
    SalesforceOpportunityService,
    OpportunityResolutionService,
    SalesforceSIMInventoryService,
    SalesforceReadThrottleGuard,
    SalesforceWriteThrottleGuard,
  ],
})
export class SalesforceModule {}
