import { CampaignGroup, ChoiceRequest, RequestInventorySource } from "../models"; import { Step } from "../steps/step"; import { CampaignModel } from "../models/CampaignModel"; import Funnel from "./funnel"; import { internalRequestSchema } from "../controllers/validation/InternalRequestValidation"; import { StepFactory } from "../steps/stepFactory"; import { KafkaConnector } from "../models/connector/KafkaProducer"; class InternalFunnel extends Funnel { constructor( campaignModel: CampaignModel, stepFactory: StepFactory, kafkaRequestProducer: KafkaConnector | null, private readonly yieldMockStep: Step | null = null ) { super( RequestInventorySource.INTERNAL, campaignModel, stepFactory, kafkaRequestProducer, internalRequestSchema ); } async chooseAdCampaigns(request: ChoiceRequest) { await this.runSteps( [ this.stepFactory.getAllowedCampaignGroupsStep( CampaignGroup.Managed | CampaignGroup.Programmatic | CampaignGroup.Marketplace | CampaignGroup.Fallback ), this.stepFactory.dvFraudStep, this.stepFactory.deviceFraudIasStep, this.stepFactory.publisherFraudIasStep, this.stepFactory.brandSafetyDvStep, this.stepFactory.brandSafetyIasStep, this.stepFactory.brandSuitabilityIasStep, this.stepFactory.bypassNormalFlowStep, this.yieldMockStep ?? this.stepFactory.yieldStep, this.stepFactory.orderingStep, this.stepFactory.speedThresholdStep, this.stepFactory.priorityStep, this.stepFactory.programmaticEnabledStep, this.stepFactory.programmaticIVTStep, this.stepFactory.programmaticResponseStep as Step, this.stepFactory.campaignSizeStep, this.stepFactory.marketplaceStep as Step, this.stepFactory.fallbackStep, ], request ); } } export default InternalFunnel;