/**
 * Repository for TenantAgentConfig.
 * 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 { TenantAgentConfig } from '../../domain/entities/tenant-agent-config.entity';

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

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

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