import { Injectable } from '@nestjs/common';
import { DataSource } from 'typeorm';
import { TenantAwareRepository } from '@it0/database';
import { Runbook } from '../../domain/entities/runbook.entity';

@Injectable()
export class RunbookRepository extends TenantAwareRepository<Runbook> {
  constructor(dataSource: DataSource) {
    super(dataSource, Runbook);
  }

  async findActive(): Promise<Runbook[]> {
    return this.withRepository((repo) =>
      repo.find({ where: { isActive: true } as any }),
    );
  }
}
