<?php

declare(strict_types=1);

final class MyronValidateOgImageAction implements MyronAction
{
    public function __construct(private readonly MyronOgImageValidator $validator)
    {
    }

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/content/seo/og-image/validate',
            method: 'POST',
            domain: 'content',
            resource: 'seo-og-image',
            verb: 'validate',
            inputSchema: ['type' => 'object', 'properties' => ['imagePath' => ['type' => 'string']], 'required' => ['imagePath']],
            outputSchema: ['type' => 'object', 'properties' => ['valid' => ['type' => 'boolean'], 'message' => ['type' => 'string']]],
            requiredScope: MyronApiScopes::CONTENT_WRITE,
            summary: 'Validate Open Graph image dimensions as a non-blocking authoring utility.',
            sideEffects: [],
            preconditions: [],
            postconditions: ['dimension validation result returned'],
            audienceClass: 4,
            adminAliases: ['validate-og-image'],
            snapshotInclude: false,
            exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok($this->validator->validateDimensions((string) ($input['imagePath'] ?? '')));
    }
}
