<?php

namespace Lucent\Schema;

use Lucent\Primitive\Collection;

class CollectionSchema implements Schema
{
    public Type $type = Type::COLLECTION;

    /**
     * @param Collection<FieldInterface> $fields
     * @param array<string> $visible
     */
    function __construct(
        public string     $name,
        public string     $label,
        public array      $visible,
        public array      $groups,
        public Collection $fields,
        public string     $folder = "",
        public string     $color = "",
        public string     $sortBy = "-_sys.updatedAt",
        public ?string    $cardTitle = null,
        public ?string    $cardImage = null,
        public int        $revisions = 0,
        public array      $read = [],
        public array      $write = [],
    )
    {
    }

    public function forJsonGenerator(): array
    {
        $schemaAr = toArray($this);
        unset($schemaAr["folder"]);
        return $schemaAr;
    }

}
