<?php

declare(strict_types=1);

final class MicTypesListAction implements MyronAction
{
    public function __construct(private readonly MicElementRegistry $registry)
    {
    }

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/content/mics/types',
            method: 'GET',
            domain: 'content.mics',
            resource: 'mic_type',
            verb: 'list',
            inputSchema: ['type' => 'object', 'properties' => []],
            outputSchema: [
                'type' => 'object',
                'properties' => [
                    'types' => ['type' => 'array'],
                ],
            ],
            requiredScope: MyronApiScopes::CONTENT_READ,
            summary: 'List registered Myron Insert Code element types.',
            sideEffects: [],
            preconditions: ['At least core mic types are bootstrapped.'],
            postconditions: [],
            audienceClass: 3,
            exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok(['types' => array_values($this->registry->knownTypes())]);
    }
}

