/**
 * Repository for AgentConfig.
 * Uses standard TypeORM repository (no schema-per-tenant — uses tenantId column filter).
 */
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { AgentConfig } from '../../domain/entities/agent-config.entity';

@Injectable()
export class AgentConfigRepository {
  constructor(
    @InjectRepository(AgentConfig)
    private readonly repo: Repository<AgentConfig>,
  ) {}

  async findByTenantId(tenantId: string): Promise<AgentConfig | null> {
    return this.repo.findOneBy({ tenantId });
  }

  async save(entity: AgentConfig): Promise<AgentConfig> {
    return this.repo.save(entity);
  }
}
