<?php

namespace Lucent\Revision;

use Illuminate\Support\Str;
use Lucent\Edge\Edge;
use Lucent\Record\FileData;
use Lucent\Record\Record;
use Lucent\Record\RecordData;
use Lucent\Record\System;

readonly class Revision
{

    /**
     * @param string $id
     * @param string $recordId
     * @param string $schema
     * @param System $_sys
     * @param RecordData $data
     * @param list<Edge> $_edges
     * @param FileData|null $_file
     */
    function __construct(
        public string     $id,
        public string     $recordId,
        public string     $schema,
        public System     $_sys,
        public RecordData $data,
        public array      $_edges,
        public ?FileData  $_file = null,

    )
    {
    }


    public static function fromRecord(Record $record, array $edges): Revision
    {
        return new Revision(
            id: (string)Str::uuid(),
            recordId: $record->id,
            schema: $record->schema,
            _sys: $record->_sys,
            data: $record->data,
            _edges: $edges,
            _file: $record->_file
        );
    }


}
