<?php

declare(strict_types=1);

final class MyronSampleHelloAction implements MyronAction
{
    public function __construct(private readonly MyronExtensionSDK $sdk)
    {
    }

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/x/myron_sample/hello',
            method: 'GET',
            domain: 'x.myron_sample.hello',
            resource: 'hello',
            verb: 'get',
            inputSchema: ['type' => 'object', 'properties' => []],
            outputSchema: [
                'type' => 'object',
                'properties' => [
                    'message' => ['type' => 'string'],
                    'siteType' => ['type' => 'string'],
                ],
            ],
            requiredScope: MyronApiScopes::CONTENT_READ,
            summary: 'Return a sample extension greeting.',
            sideEffects: [],
            preconditions: ['The myron_sample extension is enabled and granted content.read.'],
            postconditions: [],
            audienceClass: 3,
            exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok([
            'message' => 'Hello from myron-sample extension',
            'siteType' => $this->sdk->getSiteType(),
        ]);
    }
}
