import { CompositeSpecification, UniqueID } from "@repo/rdx-ddd";
import { I
{
  pascalCase;
  name;
}
Repository;
} from "../../domain/repositories"

export class {
  {
  pascalCase;
  name;
}
}NotExistsSpecification extends CompositeSpecification<UniqueID>
{
  constructor(
    private readonly repo: I{{pascalCase name}}Repository,
    private readonly transaction?: unknown
  )
  super();

  async;
  isSatisfiedBy(entityId: UniqueID)
  : Promise<boolean>
  {
    const existsOrError = await this.repo.existsById(entityId, this.transaction);
    if (existsOrError.isFailure) throw existsOrError.error;
    return existsOrError.data === false;
  }
}
