<?php

namespace Database\Factories;

use App\Models\InventorySyncRun;
use App\Models\Tenant;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\InventorySyncRun>
 */
class InventorySyncRunFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $selectionPayload = [
            'policy_types' => ['deviceConfiguration'],
            'categories' => ['Configuration'],
            'include_foundations' => false,
            'include_dependencies' => false,
        ];

        return [
            'tenant_id' => Tenant::factory(),
            'selection_hash' => hash('sha256', (string) json_encode($selectionPayload)),
            'selection_payload' => $selectionPayload,
            'status' => InventorySyncRun::STATUS_SUCCESS,
            'had_errors' => false,
            'error_codes' => [],
            'error_context' => null,
            'started_at' => now()->subMinute(),
            'finished_at' => now(),
            'items_observed_count' => 0,
            'items_upserted_count' => 0,
            'errors_count' => 0,
        ];
    }
}
