<?php

declare(strict_types=1);

final class MicTableListAction implements MyronAction
{
    public function __construct(private readonly MicTableService $service)
    {
    }

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/content/tables',
            method: 'GET',
            domain: 'content.tables',
            resource: 'table',
            verb: 'list',
            inputSchema: [
                'type' => 'object',
                'properties' => [
                    'limit' => ['type' => 'string'],
                    'offset' => ['type' => 'string'],
                ],
            ],
            outputSchema: ['type' => 'object', 'properties' => ['tables' => ['type' => 'array']]],
            requiredScope: MyronApiScopes::CONTENT_READ,
            summary: 'List reusable Content Bank tables.',
            audienceClass: 3,
            exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok($this->service->list((int) ($input['limit'] ?? 100), (int) ($input['offset'] ?? 0)));
    }
}

