<?php
/**
 * Index ability schemas.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks\Schemas;

use LolaCoreForBricks\AbilitiesProvider;
use LolaCoreForBricks\Index\IndexBuilder;

/**
 * Door 1 schema definitions for index maintenance abilities.
 */
class IndexSchemas
{
    /**
     * @return array{exact: string[], stem: string[]}
     */
    private static function keywords(): array
    {
        return [
            'exact' => [
                'design index', 'rebuild index', 'index rebuild', 'scan bricks', 'index coverage',
                'índice de diseño', 'reconstruir índice', 'cobertura del índice',
            ],
            'stem'  => ['index', 'rebuild', 'scan', 'coverage', 'índice'],
        ];
    }

    /**
     * @return array<string, array<string, mixed>>
     */
    public static function define(): array
    {
        return [
            'rebuildDesignIndex' => [
                'description' => 'Rebuild the persisted Bricks design-system index in batches. Call repeatedly until finished is true. Use getBricksOverview to read coverage between batches.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => self::keywords(),
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => [
                        'batch_size' => [
                            'type'        => 'integer',
                            'description' => 'Pages to index per batch. Defaults to ' . IndexBuilder::DEFAULT_BATCH_SIZE . '.',
                        ],
                        'restart' => [
                            'type'        => 'boolean',
                            'description' => 'When true, truncates the index and starts from scratch.',
                        ],
                    ],
                ],
            ],
        ];
    }
}
