<?php

namespace FleekDash\API\Performance;

/**
 * REST schema definitions for Performance API endpoints
 *
 * @package FleekDash\API\Performance
 * @since 2.2.0
 */
class PerformanceSchemaProvider
{
    private const JSON_SCHEMA_URI = 'http://json-schema.org/draft-04/schema#';
    private const SUCCESS_PROPERTY_DESC = 'Whether the operation was successful';

    /**
     * @return array<string, mixed>
     */
    public function getRegenerateArgs(): array
    {
        return [
            'batch_size' => [
                'description' => 'Number of images to process in one batch',
                'type'        => 'integer',
                'default'     => 10,
                'minimum'     => 1,
                'maximum'     => 50,
            ],
            'offset' => [
                'description' => 'Starting offset for batch processing',
                'type'        => 'integer',
                'default'     => 0,
                'minimum'     => 0,
            ],
            'force' => [
                'description' => 'Force start even if regeneration is in progress',
                'type'        => 'boolean',
                'default'     => false,
            ],
        ];
    }

    /**
     * @return array<string, mixed>
     */
    public function getRegenerateSchema(): array
    {
        return [
            '$schema'    => self::JSON_SCHEMA_URI,
            'title'      => 'Thumbnail Regeneration Response',
            'type'       => 'object',
            'properties' => [
                'success' => ['type' => 'boolean', 'description' => self::SUCCESS_PROPERTY_DESC],
                'message' => ['type' => 'string', 'description' => 'Human-readable message'],
                'data'    => ['type' => 'object', 'description' => 'Regeneration status data'],
            ],
        ];
    }

    /**
     * @return array<string, mixed>
     */
    public function getStatusSchema(): array
    {
        return [
            '$schema'    => self::JSON_SCHEMA_URI,
            'title'      => 'Regeneration Status Response',
            'type'       => 'object',
            'properties' => [
                'success' => ['type' => 'boolean', 'description' => self::SUCCESS_PROPERTY_DESC],
                'data'    => ['type' => 'object', 'description' => 'Current regeneration status'],
            ],
        ];
    }

    /**
     * @return array<string, mixed>
     */
    public function getStatsSchema(): array
    {
        return [
            '$schema'    => self::JSON_SCHEMA_URI,
            'title'      => 'Image Statistics Response',
            'type'       => 'object',
            'properties' => [
                'success' => ['type' => 'boolean', 'description' => self::SUCCESS_PROPERTY_DESC],
                'data'    => ['type' => 'object', 'description' => 'Image statistics data'],
            ],
        ];
    }
}
