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 } 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';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forFeature(
      [
        QueueOrderModel,
        QueueTicketModel,
        QueueItemModel,
        QueueModel,
        QueueBucketModel,
        ItemModel,
        TransactionModel,
      ],
      CONNECTION_NAME.DEFAULT,
    ),
    CqrsModule,
  ],
  controllers: [QueueController, QueueAdminController],
  providers: [
    QueueTransactionHandler,

    QueueOrchestrator,
    QueueAdminOrchestrator,

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

    IndexQueueManager,
    CallQueueManager,
    RegisterQueueManager,
    SplitQueueManager,
  ],
})
export class QueueModule {}
