import type { Sequelize } from "sequelize";
import { Result } from "@erp/core/api";
import type { Criteria, Pagination } from "@erp/core/api";
import type { I{{pascalCase name}}Repository, {{pascalCase name}} } from "../../domain";
import type { {{pascalCase name}}Model } from "../sequelize/models/{{kebabCase name}}.model";

/**
 * Repositorio concreto (Sequelize)
 * @remarks
 * - Implementa métodos por tenant (companyId) desde el inicio.
 */
export class {{pascalCase name}}Repository implements I{{pascalCase name}}Repository {
  public constructor(private readonly database: Sequelize) {}

  async create(entity: {{pascalCase name}}) {
    // TODO: usar mapper y modelo
    return Result.fail<{{pascalCase name}}>(new Error("Not implemented"));
  }

  async update(entity: {{pascalCase name}}) {
    return Result.fail<{{pascalCase name}}>(new Error("Not implemented"));
  }

  async deleteByIdInCompany(id: string, companyId: string) {
    return Result.fail<void>(new Error("Not implemented"));
  }

  async findByIdInCompany(id: string, companyId: string) {
    return Result.fail<{{pascalCase name}}>(new Error("Not implemented"));
  }

  async findByCriteriaInCompany(criteria: Criteria, companyId: string, pagination?: Pagination) {
    // TODO: aplicar where/order/limit/offset usando CriteriaToSequelizeConverter si existe en core
    return Result.fail<{ items: {{pascalCase name}}[]; total: number }>(new Error("Not implemented"));
  }
}
