<?php

declare(strict_types=1);

/** APO-194 Card 7 — GET /api/v1/design/templates */
final class MyronListTemplatesAction implements MyronAction
{
    public function __construct(private readonly MyronTemplateDefinitionRepository $repo) {}

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/design/templates', method: 'GET',
            domain: 'design', resource: 'template', verb: 'list',
            inputSchema: ['type' => 'object', 'properties' => []],
            outputSchema: ['type' => 'object', 'properties' => ['items' => ['type' => 'array']]],
            requiredScope: MyronApiScopes::DESIGN_READ,
            summary: 'List page template definitions (architectural + custom variants).',
            audienceClass: 3,
            snapshotInclude: true, snapshotKey: 'design.templates',
            exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok(['items' => $this->repo->listTemplates()]);
    }
}
