import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';

import { CqrsModule } from '@nestjs/cqrs';

import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
import {
  QueueItemModel,
  QueueModel,
  QueueOrderModel,
  QueueTicketModel,
} from './data/models/queue.model';
import { QueueController } from './infrastructure/controllers/queue.controller';
import { QueueOrchestrator } from './domain/queue.orchestrator';
import { QueueTransactionHandler } from './infrastructure/handlers/transaction.handler';
import { TransactionDataService } from '../transaction/transaction/data/services/transaction-data.service';
import { TransactionModel } from '../transaction/transaction/data/models/transaction.model';
import { TicketDataService } from './data/services/ticket.service';
import {
  QueueDataService,
  QueueOrderService,
  QueueService,
} from './data/services/queue.service';
import { QueueAdminController } from './infrastructure/controllers/queue-admin.controller';
import { QueueAdminOrchestrator } from './domain/queue-admin.orchestrator';
import { IndexQueueManager } from './domain/usecases/index-queue.manager';
import {
  CallQueueManager,
  DoneQueueManager,
} from './domain/usecases/call-queue.manager';
import { RegisterQueueManager } from './domain/usecases/register-queue.manager';
import { QueueBucketModel } from './data/models/queue-bucket.model';
import { QueueBucketReadService } from './data/services/queue-bucket';
import { SplitQueueManager } from './domain/usecases/split-queue.manager';
import { QueueTransactionCancelHandler } from './infrastructure/handlers/cancel-transaction.handler';
import { ItemQueueModel } from '../item-related/item-queue/data/models/item-queue.model';
import { QueueTimeFormula } from './domain/usecases/formula/queue-time.formula';
import { QueueJobController } from './infrastructure/controllers/queue-job.controller';
import { GenerateQueueManager } from './domain/usecases/generate-queue.manager';
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forFeature(
      [
        QueueOrderModel,
        QueueTicketModel,
        QueueItemModel,
        QueueModel,
        QueueBucketModel,
        ItemModel,
        ItemQueueModel,
        TransactionModel,
      ],
      CONNECTION_NAME.DEFAULT,
    ),
    CqrsModule,
    CouchModule,
  ],
  controllers: [QueueController, QueueAdminController, QueueJobController],
  providers: [
    QueueOrchestrator,
    QueueAdminOrchestrator,

    QueueTransactionHandler,
    QueueTransactionCancelHandler,

    TransactionDataService,
    TicketDataService,
    QueueDataService,
    QueueService,
    QueueBucketReadService,
    QueueOrderService,

    IndexQueueManager,
    CallQueueManager,
    DoneQueueManager,
    RegisterQueueManager,
    SplitQueueManager,

    QueueTimeFormula,
    GenerateQueueManager,
  ],
})
export class QueueModule {}
