import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { RawEvent } from '../entities/raw-event.entity';
import { SessionFingerprint } from '../entities/session-fingerprint.entity';
import { VisitorSalt } from '../entities/visitor-salt.entity';
import { Domain } from '../entities/domain.entity';
import { Corp } from '../entities/corp.entity';

import { DeviceEnrichmentService } from './device-enrichment.service';
import { AttributionService } from './attribution.service';
import { GovDetectionService } from './gov-detection.service';
import { IdentityService } from './identity.service';
import { DomainResolverService } from './domain-resolver.service';
import { IngestService } from './ingest.service';

/**
 * Canonical-writer module. Owns the DB-bound enrichment that used to run in the
 * collector and the {@link IngestService} that turns an edge envelope into a
 * `raw_events` row. Lives on the canonical-store host (black).
 */
@Module({
  imports: [
    TypeOrmModule.forFeature([RawEvent, SessionFingerprint, VisitorSalt, Domain, Corp]),
  ],
  providers: [
    DeviceEnrichmentService,
    AttributionService,
    GovDetectionService,
    IdentityService,
    DomainResolverService,
    IngestService,
  ],
  exports: [IngestService],
})
export class IngestModule {}
