<?php

namespace App\Domain\Shared\Domain\Contract;

use App\Domain\Shared\Domain\Model\Job;
use App\Domain\Shared\Domain\Model\JobStatus;

interface JobRepositoryInterface
{
    public function save(Job $job): void;
    public function get(string $id): ?Job;
    public function findByStatus(JobStatus $status): array;
    public function findByType(string $type): array;
    public function findPendingJobs(): array;
    public function findInProgressJobs(): array;
    public function findFailedJobs(): array;

    /**
     * @param array{
     *     status?: ?JobStatus,
     *     statuses?: ?array<JobStatus>,
     *     type?: ?string,
     *     createdAfter?: ?\DateTimeImmutable,
     *     createdBefore?: ?\DateTimeImmutable,
     *     sortBy?: string,
     *     sortOrder?: string,
     *     offset?: int,
     *     limit?: int
     * } $criteria
     * @return Job[]
     */
    public function findByCriteria(array $criteria): array;

    /**
     * @param array{
     *     status?: ?JobStatus,
     *     statuses?: ?array<JobStatus>,
     *     type?: ?string,
     *     createdAfter?: ?\DateTimeImmutable,
     *     createdBefore?: ?\DateTimeImmutable
     * } $criteria
     */
    public function countByCriteria(array $criteria): int;

    public function delete(string $id): void;

    /**
     * @param array{
     *     statuses?: ?array<JobStatus>,
     *     type?: ?string,
     *     createdAfter?: ?\DateTimeImmutable,
     *     createdBefore?: ?\DateTimeImmutable
     * } $criteria
     * @return int Nombre de jobs supprimés
     */
    public function deleteByCriteria(array $criteria): int;
}
