87d3c27b65
Formatting only: run prettier across the frontend and gofmt over the backend. Fixes struct-field alignment in domain/pool.go and pre-existing prettier drift in a few frontend files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Pool file sort keys. PoolSortManual keeps the user-defined order in
|
|
// file_pool.position; the others sort the pool's files by that file field.
|
|
const (
|
|
PoolSortManual = "manual"
|
|
PoolSortContentDatetime = "content_datetime"
|
|
PoolSortCreated = "created"
|
|
PoolSortOriginalName = "original_name"
|
|
|
|
SortOrderAsc = "asc"
|
|
SortOrderDesc = "desc"
|
|
)
|
|
|
|
// ValidPoolSortKey reports whether s is an accepted pool sort key.
|
|
func ValidPoolSortKey(s string) bool {
|
|
switch s {
|
|
case PoolSortManual, PoolSortContentDatetime, PoolSortCreated, PoolSortOriginalName:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ValidSortOrder reports whether s is an accepted sort direction.
|
|
func ValidSortOrder(s string) bool {
|
|
return s == SortOrderAsc || s == SortOrderDesc
|
|
}
|
|
|
|
// Pool is an ordered collection of files.
|
|
type Pool struct {
|
|
ID uuid.UUID
|
|
Name string
|
|
Notes *string
|
|
Metadata json.RawMessage
|
|
CreatorID int16
|
|
CreatorName string // denormalized
|
|
IsPublic bool
|
|
// SortKey / SortOrder control how the pool's files are ordered. When SortKey
|
|
// is PoolSortManual, files follow the manual position order and can be
|
|
// reordered; otherwise they are sorted automatically and reordering is a no-op.
|
|
SortKey string
|
|
SortOrder string
|
|
FileCount int
|
|
CreatedAt time.Time // extracted from UUID v7 via UUIDCreatedAt
|
|
}
|
|
|
|
// PoolFile is a File with its ordering position within a pool.
|
|
type PoolFile struct {
|
|
File
|
|
Position int
|
|
}
|
|
|
|
// PoolFilePage is the result of a cursor-based pool file listing.
|
|
type PoolFilePage struct {
|
|
Items []PoolFile
|
|
NextCursor *string
|
|
}
|
|
|
|
// PoolOffsetPage is an offset-based page of pools.
|
|
type PoolOffsetPage struct {
|
|
Items []Pool
|
|
Total int
|
|
Offset int
|
|
Limit int
|
|
}
|