<?php

declare(strict_types=1);

namespace Builder\Core\Foundation\Resources;

use Builder\Core\Foundation\Contracts\BuilderAccessible;
use Illuminate\Database\Eloquent\Model;

/**
 * Immutable value object that encapsulates a single resource write operation.
 *
 * Built by ResourcePersistenceService from validated + stripped request data.
 * Passed through all write-pipeline steps so each step has full context.
 */
readonly class ResourceWriteContext
{
    /**
     * @param  array<string, mixed>  $baseData  Non-translatable, non-virtual fields ready to fill.
     * @param  array<string, mixed>  $translatableData  Translatable fields keyed by name.
     * @param  array<string, mixed>  $requestData  Full raw payload (needed by field handlers).
     * @param  string  $action  'creating' | 'updating'
     */
    public function __construct(
        public ResourceDefinition $definition,
        public Model $record,
        public array $baseData,
        public array $translatableData,
        public array $requestData,
        public ?string $locale,
        public string $action,
        public BuilderAccessible $user,
    ) {}
}
