import { Provider } from '@nestjs/common';
import { AnalyticsService } from './AnalyticsService';
import { RecordPageViewUseCase } from './use-cases/RecordPageViewUseCase';
import { RecordEngagementUseCase } from './use-cases/RecordEngagementUseCase';

const Logger_TOKEN = 'Logger_TOKEN';
const IPAGE_VIEW_REPO_TOKEN = 'IPageViewRepository_TOKEN';
const IENGAGEMENT_REPO_TOKEN = 'IEngagementRepository_TOKEN';
const RECORD_PAGE_VIEW_USE_CASE_TOKEN = 'RecordPageViewUseCase_TOKEN';
const RECORD_ENGAGEMENT_USE_CASE_TOKEN = 'RecordEngagementUseCase_TOKEN';

import type { Logger } from '@core/shared/application';
import type { IPageViewRepository } from '@core/analytics/application/repositories/IPageViewRepository';
import type { IEngagementRepository } from '@core/analytics/domain/repositories/IEngagementRepository';

import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
import { InMemoryPageViewRepository } from '@adapters/analytics/persistence/inmemory/InMemoryPageViewRepository';
import { InMemoryEngagementRepository } from '@adapters/analytics/persistence/inmemory/InMemoryEngagementRepository';

export const AnalyticsProviders: Provider[] = [
  AnalyticsService,
  RecordPageViewUseCase,
  RecordEngagementUseCase,
  {
    provide: Logger_TOKEN,
    useClass: ConsoleLogger,
  },
  {
    provide: IPAGE_VIEW_REPO_TOKEN,
    useClass: InMemoryPageViewRepository,
  },
  {
    provide: IENGAGEMENT_REPO_TOKEN,
    useClass: InMemoryEngagementRepository,
  },
  {
    provide: RECORD_PAGE_VIEW_USE_CASE_TOKEN,
    useClass: RecordPageViewUseCase,
  },
  {
    provide: RECORD_ENGAGEMENT_USE_CASE_TOKEN,
    useClass: RecordEngagementUseCase,
  },
];