package store

import "time"

type User struct {
	PublicKey string    `json:"publicKey"`
	Inviter   string    `json:"inviter,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
}

type Challenge struct {
	Nonce     string
	PublicKey string
	IP        string
	ExpiresAt time.Time
	Used      bool
}

// UserLogin records a successful login for a user (ip, created_at)
type UserLogin struct {
	PublicKey string
	IP        string
	CreatedAt time.Time
}

type Session struct {
	Token     string
	PublicKey string
	ExpiresAt time.Time
}

type Invitation struct {
	JTI              string
	InviterPublicKey string
	InviteePublicKey string
	ExpiresAt        time.Time
	MaxUses          int
	UsedCount        int
}

type Collection struct {
	ID        string    `json:"id"`
	OwnerKey  string    `json:"ownerKey"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
}

type Point struct {
	Type        string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
}

type Feature struct {
	ID           string                 `json:"id"`
	CollectionID string                 `json:"collectionId"`
	OwnerKey     string                 `json:"ownerKey"`
	Type         string                 `json:"type"`
	Geometry     Point                  `json:"geometry"`
	Properties   map[string]interface{} `json:"properties"`
	CreatedAt    time.Time              `json:"createdAt"`
	UpdatedAt    time.Time              `json:"updatedAt"`
}

type Asset struct {
	ID        string    `json:"id"`
	OwnerKey  string    `json:"ownerKey"`
	Checksum  string    `json:"checksum"`
	Ext       string    `json:"ext"`
	Kind      string    `json:"kind"`
	MimeType  string    `json:"mimeType,omitempty"`
	SizeBytes int64     `json:"sizeBytes"`
	ObjectKey string    `json:"objectKey"`
	IsPublic  bool      `json:"isPublic"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type FeatureAsset struct {
	Asset
	FeatureID   string    `json:"featureId"`
	Name        string    `json:"name,omitempty"`
	Description string    `json:"description,omitempty"`
	LinkedAt    time.Time `json:"linkedAt"`
}
