/*
 * Copyright 2026 Oleg Borodin <onborodin@gmail.com>
 */
package descr

import (
	"path"
)

type File struct {
	ID         string `db:"id"          json:"id,omitempty"         yaml:"id,omitempty"`
	Collection string `db:"collection"  json:"collection,omitempty" yaml:"collection,omitempty"`
	Name       string `db:"name"        json:"name,omitempty"       yaml:"name,omitempty"`
	Type       string `db:"type"        json:"type,omitempty"       yaml:"type,omitempty"`
	Checksum   string `db:"checksum"    json:"checksum,omitempty"   yaml:"checksum,omitempty"`
	Size       int64  `db:"size"        json:"size,omitempty"       yaml:"size,omitempty"`
	CreatedAt  string `db:"created_at"  json:"createdAt,omitempty"  yaml:"createdAt,omitempty"`
	UpdatedAt  string `db:"updated_at"  json:"updatedAt,omitempty"  yaml:"updatedAt,omitempty"`
	CreatedBy  string `db:"created_by"  json:"createdBy,omitempty"  yaml:"createdBy,omitempty"`
	UpdatedBy  string `db:"updated_by"  json:"updatedBy,omitempty"  yaml:"updatedBy,omitempty"`
	HelmMeta   string `db:"helm_meta"   json:"helmMeta,omitempty"   yaml:"helmMeta,omitempty"`
	HelmHash   string `db:"helm_hash"   json:"helmHash,omitempty"   yaml:"helmHash,omitempty"`
}

type Files struct {
	files []File
}

func NewFiles() *Files {
	return &Files{
		files: make([]File, 0),
	}
}

func xxxNewFiles(files []File) *Files {
	return &Files{
		files: files,
	}
}

func (fi *Files) Set(files []File) {
	fi.files = files
}

func (fi *Files) ArrayPtr() *[]File {
	return &fi.files
}

func (fi *Files) Array() []File {
	return fi.files
}

func (fi *Files) List() []string {
	list := make([]string, 0)
	for _, file := range fi.files {
		list = append(list, path.Join(file.Collection, file.Name))
	}
	return list
}
