schema

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownResource = errors.New("unknown resource")
View Source
var ErrUnknownVerb = errors.New("unknown verb")

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Model
	Owner                 string
	Site                  string
	Name                  string `gorm:"not null"`
	HourlyAPIRequestLimit uint   `gorm:"not null;default:1000"`
	KeyPrefix             string
	KeyHash               string `gorm:"index"`
	UsedAt                time.Time
	Scopes                datatypes.JSONSlice[*Scope]
	ExpiresAt             time.Time
}

func (*APIKey) Can added in v0.0.16

func (a *APIKey) Can(ctx context.Context, owner, site string, resource Resource, verb Verb) bool

func (*APIKey) ScopeList added in v0.0.13

func (a *APIKey) ScopeList() (o []string)

type CachedSite

type CachedSite struct {
	ID                          uint64
	Domain                      string
	StatsStartDate              time.Time
	IngestRateLimitScaleSeconds uint64
	IngestRateLimitThreshold    sql.NullInt64
	UserID                      uint64
}

type EmailVerificationCode

type EmailVerificationCode struct {
	Model
	Code   uint64
	UserID sql.NullInt64
}

type Goal

type Goal struct {
	Model
	SiteID    uint64
	Name      string `gorm:"uniqueIndex"`
	EventName string
	PagePath  string
}

type Membership added in v0.0.16

type Membership struct {
	Model
	UserID uint64
	Site   *Site
	SiteID uint64
	User   *User
	Role   string `gorm:"not null;default:'owner';check:role in ('owner', 'admin', 'viewer')"`
}

type Model

type Model struct {
	ID        uint64    `gorm:"primarykey;autoIncrement:true" json:"id"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type Resource added in v0.0.13

type Resource uint
const (
	Sites Resource = iota
	Stats
)

func (*Resource) From added in v0.0.13

func (r *Resource) From(s string) error

func (Resource) String added in v0.0.13

func (r Resource) String() string

type Scope added in v0.0.13

type Scope struct {
	Resource Resource
	Verbs    []Verb
}

type ScopeList added in v0.0.13

type ScopeList datatypes.JSONSlice[*Scope]

func ParseScopes added in v0.0.13

func ParseScopes(e ...string) (ScopeList, error)

func (ScopeList) Can added in v0.0.13

func (ls ScopeList) Can(resource Resource, verb Verb) bool

type Site

type Site struct {
	Model
	Domain          string `gorm:"uniqueIndex" json:"domain"`
	Timezone        string `gorm:"default:UTC" json:"timezone"`
	Public          bool   `gorm:"not null;default:false" json:"public"`
	Description     string
	StatsStartDate  time.Time `json:"statsStartDate"`
	IngestRateLimit sql.NullFloat64
	UserID          uint64
	Goals           []*Goal
}

type User

type User struct {
	Model
	Name                   string `gorm:"uniqueIndex"`
	FullName               string
	Email                  string `gorm:"uniqueIndex"`
	PasswordHash           string
	Sites                  []*Site
	EmailVerificationCodes []*EmailVerificationCode `gorm:"constraint:OnDelete:CASCADE;"`
	APIKeys                []*APIKey                `gorm:"foreignKey:Owner;references:Name"`
	LastSeen               time.Time
	EmailVerified          bool `gorm:"not null;default:false"`
}

type Verb added in v0.0.13

type Verb uint
const (
	All Verb = iota
	Get
	List
	Create
	Update
	Delete
)

func (*Verb) From added in v0.0.13

func (v *Verb) From(s string) error

func (Verb) String added in v0.0.13

func (v Verb) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL