hunk.code_window: const PROVIDERS = [InboundParseQueueService, GetMxRecord];
   @Module({
     imports: [SharedModule, AuthModule],
     controllers: [InboundParseController],
  
hunk.labels: keep replace keep keep keep keep
hunk.after_edit: const PROVIDERS = [InboundParseQueueService, GetMxRecord, CompileTemplate];
  
hunk.file_path: apps/api/src/app/inbound-parse/inbound-parse.module.ts
hunk.type: replace
file: import { Queue } from 'bullmq';
  import { JobRepository, JobStatusEnum } from '@novu/dal';
  import { StepTypeEnum } from '@novu/shared';
  
  import { QueueService } from './queue.service';
  
  export class JobsService {
    private jobRepository = new JobRepository();
    public queueService: QueueService;
    public queue: Queue;
  
    constructor() {
      this.queueService = new QueueService('trigger-handler');
      this.queue = this.queueService.queue;
    }
  
    public async awaitParsingEvents() {
      let waitingCount = 0;
      let parsedEvents = 0;
      do {
        waitingCount = await this.queue.getWaitingCount();
        parsedEvents = await this.queue.getActiveCount();
      } while (parsedEvents > 0 || waitingCount > 0);
    }
  
    public async awaitRunningJobs({
      templateId,
      organizationId,
      delay,
      unfinishedJobs = 0,
    }: {
      templateId?: string | string[];
      organizationId: string;
      delay?: boolean;
      unfinishedJobs?: number;
    }) {
      let runningJobs = 0;
      let waitingCount = 0;
      let parsedEvents = 0;
      do {
        waitingCount = await this.queue.getWaitingCount();
        parsedEvents = await this.queue.getActiveCount();
        runningJobs = await this.jobRepository.count({
          _organizationId: organizationId,
          type: {
            $nin: [delay ? StepTypeEnum.DELAY : StepTypeEnum.DIGEST],
          },
          _templateId: Array.isArray(templateId) ? { $in: templateId } : templateId,
          status: {
            $in: [JobStatusEnum.PENDING, JobStatusEnum.QUEUED, JobStatusEnum.RUNNING],
          },
        });
      } while (parsedEvents > 0 || waitingCount > 0 || runningJobs > unfinishedJobs);
    }
  }
  