repo

package
v0.0.0-...-6fd8457 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package repo provides the data access layer for the application.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDocExtension = errors.New("invalid document extension")

Functions

This section is empty.

Types

type AllRepos

type AllRepos struct {
	Users       *UserRepository
	AuthTokens  *TokenRepository
	Groups      *GroupRepository
	Locations   *LocationRepository
	Labels      *LabelRepository
	Items       *ItemsRepository
	Docs        *DocumentRepository
	Attachments *AttachmentRepo
	MaintEntry  *MaintenanceEntryRepository
	Notifiers   *NotifierRepository
}

AllRepos is a container for all the repository interfaces

func New

func New(db *ent.Client, bus *eventbus.EventBus, root string) *AllRepos

type AssetID

type AssetID int

func ParseAssetID

func ParseAssetID(s string) (AID AssetID, ok bool)

func ParseAssetIDBytes

func ParseAssetIDBytes(d []byte) (AID AssetID, ok bool)

func (AssetID) Int

func (aid AssetID) Int() int

func (AssetID) MarshalCSV

func (aid AssetID) MarshalCSV() (string, error)

func (AssetID) MarshalJSON

func (aid AssetID) MarshalJSON() ([]byte, error)

func (AssetID) Nil

func (aid AssetID) Nil() bool

func (AssetID) String

func (aid AssetID) String() string

func (*AssetID) UnmarshalCSV

func (aid *AssetID) UnmarshalCSV(d string) error

func (*AssetID) UnmarshalJSON

func (aid *AssetID) UnmarshalJSON(d []byte) error

type AttachmentRepo

type AttachmentRepo struct {
	// contains filtered or unexported fields
}

AttachmentRepo is a repository for Attachments table that links Items to Documents While also specifying the type of the attachment. This _ONLY_ provides basic Create Update And Delete operations. For accessing the actual documents, use the Items repository since it provides the attachments with the documents.

func (*AttachmentRepo) Create

func (r *AttachmentRepo) Create(ctx context.Context, itemID, docID uuid.UUID, typ attachment.Type) (*ent.Attachment, error)

func (*AttachmentRepo) Delete

func (r *AttachmentRepo) Delete(ctx context.Context, id uuid.UUID) error

func (*AttachmentRepo) Get

func (r *AttachmentRepo) Get(ctx context.Context, id uuid.UUID) (*ent.Attachment, error)

func (*AttachmentRepo) Update

func (r *AttachmentRepo) Update(ctx context.Context, itemID uuid.UUID, data *ItemAttachmentUpdate) (*ent.Attachment, error)

type DocumentCreate

type DocumentCreate struct {
	Title   string    `json:"title"`
	Content io.Reader `json:"content"`
}

type DocumentOut

type DocumentOut struct {
	ID    uuid.UUID `json:"id"`
	Title string    `json:"title"`
	Path  string    `json:"path"`
}

type DocumentRepository

type DocumentRepository struct {
	// contains filtered or unexported fields
}

func (*DocumentRepository) Create

func (*DocumentRepository) Delete

func (r *DocumentRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*DocumentRepository) Get

func (*DocumentRepository) GetAll

func (r *DocumentRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]DocumentOut, error)

func (*DocumentRepository) Rename

func (r *DocumentRepository) Rename(ctx context.Context, id uuid.UUID, title string) (DocumentOut, error)

type FieldQuery

type FieldQuery struct {
	Name  string
	Value string
}

type FlatTreeItem

type FlatTreeItem struct {
	ID       uuid.UUID
	Name     string
	Type     string
	ParentID uuid.UUID
	Level    int
}

type Group

type Group struct {
	ID        uuid.UUID `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
	UpdatedAt time.Time `json:"updatedAt,omitempty"`
	Currency  string    `json:"currency,omitempty"`
}

type GroupInvitation

type GroupInvitation struct {
	ID        uuid.UUID `json:"id"`
	ExpiresAt time.Time `json:"expiresAt"`
	Uses      int       `json:"uses"`
	Group     Group     `json:"group"`
}

type GroupInvitationCreate

type GroupInvitationCreate struct {
	Token     []byte    `json:"-"`
	ExpiresAt time.Time `json:"expiresAt"`
	Uses      int       `json:"uses"`
}

type GroupRepository

type GroupRepository struct {
	// contains filtered or unexported fields
}

func NewGroupRepository

func NewGroupRepository(db *ent.Client) *GroupRepository

func (*GroupRepository) GetAllGroups

func (r *GroupRepository) GetAllGroups(ctx context.Context) ([]Group, error)

func (*GroupRepository) GroupByID

func (r *GroupRepository) GroupByID(ctx context.Context, id uuid.UUID) (Group, error)

func (*GroupRepository) GroupCreate

func (r *GroupRepository) GroupCreate(ctx context.Context, name string) (Group, error)

func (*GroupRepository) GroupUpdate

func (r *GroupRepository) GroupUpdate(ctx context.Context, ID uuid.UUID, data GroupUpdate) (Group, error)

func (*GroupRepository) InvitationCreate

func (r *GroupRepository) InvitationCreate(ctx context.Context, groupID uuid.UUID, invite GroupInvitationCreate) (GroupInvitation, error)

func (*GroupRepository) InvitationGet

func (r *GroupRepository) InvitationGet(ctx context.Context, token []byte) (GroupInvitation, error)

func (*GroupRepository) InvitationPurge

func (r *GroupRepository) InvitationPurge(ctx context.Context) (amount int, err error)

InvitationPurge removes all expired invitations or those that have been used up. It returns the number of deleted invitations.

func (*GroupRepository) InvitationUpdate

func (r *GroupRepository) InvitationUpdate(ctx context.Context, id uuid.UUID, uses int) error

func (*GroupRepository) StatsGroup

func (r *GroupRepository) StatsGroup(ctx context.Context, GID uuid.UUID) (GroupStatistics, error)

func (*GroupRepository) StatsLabelsByPurchasePrice

func (r *GroupRepository) StatsLabelsByPurchasePrice(ctx context.Context, GID uuid.UUID) ([]TotalsByOrganizer, error)

func (*GroupRepository) StatsLocationsByPurchasePrice

func (r *GroupRepository) StatsLocationsByPurchasePrice(ctx context.Context, GID uuid.UUID) ([]TotalsByOrganizer, error)

func (*GroupRepository) StatsPurchasePrice

func (r *GroupRepository) StatsPurchasePrice(ctx context.Context, GID uuid.UUID, start, end time.Time) (*ValueOverTime, error)

type GroupStatistics

type GroupStatistics struct {
	TotalUsers        int     `json:"totalUsers"`
	TotalItems        int     `json:"totalItems"`
	TotalLocations    int     `json:"totalLocations"`
	TotalLabels       int     `json:"totalLabels"`
	TotalItemPrice    float64 `json:"totalItemPrice"`
	TotalWithWarranty int     `json:"totalWithWarranty"`
}

type GroupUpdate

type GroupUpdate struct {
	Name     string `json:"name"`
	Currency string `json:"currency"`
}

type HasID

type HasID interface {
	GetID() uuid.UUID
}

HasID is an interface to entities that have an ID uuid.UUID field and a GetID() method. This interface is fulfilled by all entities generated by entgo.io/ent via a custom template

type ItemAttachment

type ItemAttachment struct {
	ID        uuid.UUID   `json:"id"`
	CreatedAt time.Time   `json:"createdAt"`
	UpdatedAt time.Time   `json:"updatedAt"`
	Type      string      `json:"type"`
	Document  DocumentOut `json:"document"`
	Primary   bool        `json:"primary"`
}

func ToItemAttachment

func ToItemAttachment(attachment *ent.Attachment) ItemAttachment

type ItemAttachmentUpdate

type ItemAttachmentUpdate struct {
	ID      uuid.UUID `json:"-"`
	Type    string    `json:"type"`
	Title   string    `json:"title"`
	Primary bool      `json:"primary"`
}

type ItemCreate

type ItemCreate struct {
	ImportRef   string    `json:"-"`
	ParentID    uuid.UUID `json:"parentId"    extensions:"x-nullable"`
	Name        string    `json:"name"        validate:"required,min=1,max=255"`
	Description string    `json:"description" validate:"max=1000"`
	AssetID     AssetID   `json:"-"`

	// Edges
	LocationID uuid.UUID   `json:"locationId"`
	LabelIDs   []uuid.UUID `json:"labelIds"`
}

type ItemField

type ItemField struct {
	ID           uuid.UUID `json:"id,omitempty"`
	Type         string    `json:"type"`
	Name         string    `json:"name"`
	TextValue    string    `json:"textValue"`
	NumberValue  int       `json:"numberValue"`
	BooleanValue bool      `json:"booleanValue"`
}

type ItemOut

type ItemOut struct {
	Parent *ItemSummary `json:"parent,omitempty" extensions:"x-nullable,x-omitempty"`
	ItemSummary
	AssetID AssetID `json:"assetId,string"`

	SerialNumber string `json:"serialNumber"`
	ModelNumber  string `json:"modelNumber"`
	Manufacturer string `json:"manufacturer"`

	// Warranty
	LifetimeWarranty bool       `json:"lifetimeWarranty"`
	WarrantyExpires  types.Date `json:"warrantyExpires"`
	WarrantyDetails  string     `json:"warrantyDetails"`

	// Purchase
	PurchaseTime types.Date `json:"purchaseTime"`
	PurchaseFrom string     `json:"purchaseFrom"`

	// Sold
	SoldTime  types.Date `json:"soldTime"`
	SoldTo    string     `json:"soldTo"`
	SoldPrice float64    `json:"soldPrice,string"`
	SoldNotes string     `json:"soldNotes"`

	// Extras
	Notes string `json:"notes"`

	Attachments []ItemAttachment `json:"attachments"`
	Fields      []ItemField      `json:"fields"`
}

type ItemPatch

type ItemPatch struct {
	ID        uuid.UUID `json:"id"`
	Quantity  *int      `json:"quantity,omitempty" extensions:"x-nullable,x-omitempty"`
	ImportRef *string   `json:"-,omitempty"        extensions:"x-nullable,x-omitempty"`
}

type ItemPath

type ItemPath struct {
	Type ItemType  `json:"type"`
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

type ItemQuery

type ItemQuery struct {
	Page            int
	PageSize        int
	Search          string       `json:"search"`
	AssetID         AssetID      `json:"assetId"`
	LocationIDs     []uuid.UUID  `json:"locationIds"`
	LabelIDs        []uuid.UUID  `json:"labelIds"`
	ParentItemIDs   []uuid.UUID  `json:"parentIds"`
	SortBy          string       `json:"sortBy"`
	IncludeArchived bool         `json:"includeArchived"`
	Fields          []FieldQuery `json:"fields"`
	OrderBy         string       `json:"orderBy"`
}

type ItemSummary

type ItemSummary struct {
	ImportRef   string    `json:"-"`
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Quantity    int       `json:"quantity"`
	Insured     bool      `json:"insured"`
	Archived    bool      `json:"archived"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`

	PurchasePrice float64 `json:"purchasePrice,string"`

	// Edges
	Location *LocationSummary `json:"location,omitempty" extensions:"x-nullable,x-omitempty"`
	Labels   []LabelSummary   `json:"labels"`

	ImageID *uuid.UUID `json:"imageId,omitempty"`
}

type ItemType

type ItemType string
const (
	ItemTypeLocation ItemType = "location"
	ItemTypeItem     ItemType = "item"
)

type ItemUpdate

type ItemUpdate struct {
	ParentID    uuid.UUID `json:"parentId"    extensions:"x-nullable,x-omitempty"`
	ID          uuid.UUID `json:"id"`
	AssetID     AssetID   `json:"assetId"     swaggertype:"string"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Quantity    int       `json:"quantity"`
	Insured     bool      `json:"insured"`
	Archived    bool      `json:"archived"`

	// Edges
	LocationID uuid.UUID   `json:"locationId"`
	LabelIDs   []uuid.UUID `json:"labelIds"`

	// Identifications
	SerialNumber string `json:"serialNumber"`
	ModelNumber  string `json:"modelNumber"`
	Manufacturer string `json:"manufacturer"`

	// Warranty
	LifetimeWarranty bool       `json:"lifetimeWarranty"`
	WarrantyExpires  types.Date `json:"warrantyExpires"`
	WarrantyDetails  string     `json:"warrantyDetails"`

	// Purchase
	PurchaseTime  types.Date `json:"purchaseTime"`
	PurchaseFrom  string     `json:"purchaseFrom"`
	PurchasePrice float64    `json:"purchasePrice,string"`

	// Sold
	SoldTime  types.Date `json:"soldTime"`
	SoldTo    string     `json:"soldTo"`
	SoldPrice float64    `json:"soldPrice,string"`
	SoldNotes string     `json:"soldNotes"`

	// Extras
	Notes  string      `json:"notes"`
	Fields []ItemField `json:"fields"`
}

type ItemsRepository

type ItemsRepository struct {
	// contains filtered or unexported fields
}

func (*ItemsRepository) CheckRef

func (e *ItemsRepository) CheckRef(ctx context.Context, GID uuid.UUID, ref string) (bool, error)

func (*ItemsRepository) Create

func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCreate) (ItemOut, error)

func (*ItemsRepository) Delete

func (e *ItemsRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*ItemsRepository) DeleteByGroup

func (e *ItemsRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error

func (*ItemsRepository) GetAll

func (e *ItemsRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemOut, error)

GetAll returns all the items in the database with the Labels and Locations eager loaded.

func (*ItemsRepository) GetAllCustomFieldNames

func (e *ItemsRepository) GetAllCustomFieldNames(ctx context.Context, GID uuid.UUID) ([]string, error)

func (*ItemsRepository) GetAllCustomFieldValues

func (e *ItemsRepository) GetAllCustomFieldValues(ctx context.Context, GID uuid.UUID, name string) ([]string, error)

func (*ItemsRepository) GetAllZeroAssetID

func (e *ItemsRepository) GetAllZeroAssetID(ctx context.Context, GID uuid.UUID) ([]ItemSummary, error)

func (*ItemsRepository) GetAllZeroImportRef

func (e *ItemsRepository) GetAllZeroImportRef(ctx context.Context, GID uuid.UUID) ([]uuid.UUID, error)

func (*ItemsRepository) GetByRef

func (e *ItemsRepository) GetByRef(ctx context.Context, GID uuid.UUID, ref string) (ItemOut, error)

func (*ItemsRepository) GetHighestAssetID

func (e *ItemsRepository) GetHighestAssetID(ctx context.Context, GID uuid.UUID) (AssetID, error)

func (*ItemsRepository) GetOne

func (e *ItemsRepository) GetOne(ctx context.Context, id uuid.UUID) (ItemOut, error)

GetOne returns a single item by ID. If the item does not exist, an error is returned. See also: GetOneByGroup to ensure that the item belongs to a specific group.

func (*ItemsRepository) GetOneByGroup

func (e *ItemsRepository) GetOneByGroup(ctx context.Context, gid, id uuid.UUID) (ItemOut, error)

GetOneByGroup returns a single item by ID. If the item does not exist, an error is returned. GetOneByGroup ensures that the item belongs to a specific group.

func (*ItemsRepository) Patch

func (e *ItemsRepository) Patch(ctx context.Context, GID, ID uuid.UUID, data ItemPatch) error

func (*ItemsRepository) QueryByAssetID

func (e *ItemsRepository) QueryByAssetID(ctx context.Context, gid uuid.UUID, assetID AssetID, page int, pageSize int) (PaginationResult[ItemSummary], error)

QueryByAssetID returns items by asset ID. If the item does not exist, an error is returned.

func (*ItemsRepository) QueryByGroup

QueryByGroup returns a list of items that belong to a specific group based on the provided query.

func (*ItemsRepository) SetAssetID

func (e *ItemsRepository) SetAssetID(ctx context.Context, GID uuid.UUID, ID uuid.UUID, assetID AssetID) error

func (*ItemsRepository) SetPrimaryPhotos

func (e *ItemsRepository) SetPrimaryPhotos(ctx context.Context, GID uuid.UUID) (int, error)

func (*ItemsRepository) UpdateByGroup

func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data ItemUpdate) (ItemOut, error)

func (*ItemsRepository) ZeroOutTimeFields

func (e *ItemsRepository) ZeroOutTimeFields(ctx context.Context, GID uuid.UUID) (int, error)

ZeroOutTimeFields is a helper function that can be invoked via the UI by a group member which will set all date fields to the beginning of the day.

This is designed to resolve a long-time bug that has since been fixed with the time selector on the frontend. This function is intended to be used as a one-time fix for existing databases and may be removed in the future.

type LabelCreate

type LabelCreate struct {
	Name        string `json:"name"        validate:"required,min=1,max=255"`
	Description string `json:"description" validate:"max=255"`
	Color       string `json:"color"`
}

type LabelOut

type LabelOut struct {
	LabelSummary
}

type LabelRepository

type LabelRepository struct {
	// contains filtered or unexported fields
}

func (*LabelRepository) Create

func (r *LabelRepository) Create(ctx context.Context, groupID uuid.UUID, data LabelCreate) (LabelOut, error)

func (*LabelRepository) DeleteByGroup

func (r *LabelRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error

func (*LabelRepository) GetAll

func (r *LabelRepository) GetAll(ctx context.Context, groupID uuid.UUID) ([]LabelSummary, error)

func (*LabelRepository) GetOne

func (r *LabelRepository) GetOne(ctx context.Context, ID uuid.UUID) (LabelOut, error)

func (*LabelRepository) GetOneByGroup

func (r *LabelRepository) GetOneByGroup(ctx context.Context, gid, ld uuid.UUID) (LabelOut, error)

func (*LabelRepository) UpdateByGroup

func (r *LabelRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data LabelUpdate) (LabelOut, error)

type LabelSummary

type LabelSummary struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type LabelUpdate

type LabelUpdate struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"        validate:"required,min=1,max=255"`
	Description string    `json:"description" validate:"max=255"`
	Color       string    `json:"color"`
}

type LocationCreate

type LocationCreate struct {
	Name        string    `json:"name"`
	ParentID    uuid.UUID `json:"parentId"    extensions:"x-nullable"`
	Description string    `json:"description"`
}

type LocationOut

type LocationOut struct {
	Parent *LocationSummary `json:"parent,omitempty"`
	LocationSummary
	Children []LocationSummary `json:"children"`
}

type LocationOutCount

type LocationOutCount struct {
	LocationSummary
	ItemCount int `json:"itemCount"`
}

type LocationQuery

type LocationQuery struct {
	FilterChildren bool `json:"filterChildren" schema:"filterChildren"`
}

type LocationRepository

type LocationRepository struct {
	// contains filtered or unexported fields
}

func (*LocationRepository) Create

func (*LocationRepository) DeleteByGroup

func (r *LocationRepository) DeleteByGroup(ctx context.Context, GID, ID uuid.UUID) error

func (*LocationRepository) Get

func (*LocationRepository) GetAll

GetAll returns all locations with item count field populated

func (*LocationRepository) GetOneByGroup

func (r *LocationRepository) GetOneByGroup(ctx context.Context, GID, ID uuid.UUID) (LocationOut, error)

func (*LocationRepository) PathForLoc

func (r *LocationRepository) PathForLoc(ctx context.Context, GID, locID uuid.UUID) ([]ItemPath, error)

func (*LocationRepository) Tree

func (r *LocationRepository) Tree(ctx context.Context, GID uuid.UUID, tq TreeQuery) ([]TreeItem, error)

func (*LocationRepository) UpdateByGroup

func (r *LocationRepository) UpdateByGroup(ctx context.Context, GID, ID uuid.UUID, data LocationUpdate) (LocationOut, error)

type LocationSummary

type LocationSummary struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type LocationUpdate

type LocationUpdate struct {
	ParentID    uuid.UUID `json:"parentId"    extensions:"x-nullable"`
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
}

type MaintenanceEntry

type MaintenanceEntry struct {
	ID            uuid.UUID  `json:"id"`
	CompletedDate types.Date `json:"completedDate"`
	ScheduledDate types.Date `json:"scheduledDate"`
	Name          string     `json:"name"`
	Description   string     `json:"description"`
	Cost          float64    `json:"cost,string"`
}

type MaintenanceEntryCreate

type MaintenanceEntryCreate struct {
	CompletedDate types.Date `json:"completedDate"`
	ScheduledDate types.Date `json:"scheduledDate"`
	Name          string     `json:"name"          validate:"required"`
	Description   string     `json:"description"`
	Cost          float64    `json:"cost,string"`
}

func (MaintenanceEntryCreate) Validate

func (mc MaintenanceEntryCreate) Validate() error

type MaintenanceEntryRepository

type MaintenanceEntryRepository struct {
	// contains filtered or unexported fields
}

MaintenanceEntryRepository is a repository for maintenance entries that are associated with an item in the database. An entry represents a maintenance event that has been performed on an item.

func (*MaintenanceEntryRepository) Create

func (*MaintenanceEntryRepository) Delete

func (*MaintenanceEntryRepository) GetLog

func (r *MaintenanceEntryRepository) GetLog(ctx context.Context, groupID, itemID uuid.UUID, query MaintenanceLogQuery) (MaintenanceLog, error)

func (*MaintenanceEntryRepository) GetScheduled

func (r *MaintenanceEntryRepository) GetScheduled(ctx context.Context, GID uuid.UUID, dt types.Date) ([]MaintenanceEntry, error)

func (*MaintenanceEntryRepository) Update

type MaintenanceEntryUpdate

type MaintenanceEntryUpdate struct {
	CompletedDate types.Date `json:"completedDate"`
	ScheduledDate types.Date `json:"scheduledDate"`
	Name          string     `json:"name"`
	Description   string     `json:"description"`
	Cost          float64    `json:"cost,string"`
}

func (MaintenanceEntryUpdate) Validate

func (mu MaintenanceEntryUpdate) Validate() error

type MaintenanceLog

type MaintenanceLog struct {
	ItemID      uuid.UUID          `json:"itemId"`
	CostAverage float64            `json:"costAverage"`
	CostTotal   float64            `json:"costTotal"`
	Entries     []MaintenanceEntry `json:"entries"`
}

type MaintenanceLogQuery

type MaintenanceLogQuery struct {
	Completed bool `json:"completed" schema:"completed"`
	Scheduled bool `json:"scheduled" schema:"scheduled"`
}

type MapFunc

type MapFunc[T any, U any] func(T) U

func (MapFunc[T, U]) Map

func (a MapFunc[T, U]) Map(v T) U

func (MapFunc[T, U]) MapEach

func (a MapFunc[T, U]) MapEach(v []T) []U

func (MapFunc[T, U]) MapEachErr

func (a MapFunc[T, U]) MapEachErr(v []T, err error) ([]U, error)

func (MapFunc[T, U]) MapErr

func (a MapFunc[T, U]) MapErr(v T, err error) (U, error)

type NotifierCreate

type NotifierCreate struct {
	Name     string `json:"name"     validate:"required,min=1,max=255"`
	IsActive bool   `json:"isActive"`
	URL      string `json:"url"      validate:"required,shoutrrr"`
}

type NotifierOut

type NotifierOut struct {
	ID        uuid.UUID `json:"id"`
	UserID    uuid.UUID `json:"userId"`
	GroupID   uuid.UUID `json:"groupId"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`

	Name     string `json:"name"`
	IsActive bool   `json:"isActive"`
	URL      string `json:"-"` // URL field is not exposed to the client
}

type NotifierRepository

type NotifierRepository struct {
	// contains filtered or unexported fields
}

func NewNotifierRepository

func NewNotifierRepository(db *ent.Client) *NotifierRepository

func (*NotifierRepository) Create

func (r *NotifierRepository) Create(ctx context.Context, groupID, userID uuid.UUID, input NotifierCreate) (NotifierOut, error)

func (*NotifierRepository) Delete

func (r *NotifierRepository) Delete(ctx context.Context, userID uuid.UUID, ID uuid.UUID) error

func (*NotifierRepository) GetActiveByGroup

func (r *NotifierRepository) GetActiveByGroup(ctx context.Context, groupID uuid.UUID) ([]NotifierOut, error)

func (*NotifierRepository) GetByGroup

func (r *NotifierRepository) GetByGroup(ctx context.Context, groupID uuid.UUID) ([]NotifierOut, error)

func (*NotifierRepository) GetByUser

func (r *NotifierRepository) GetByUser(ctx context.Context, userID uuid.UUID) ([]NotifierOut, error)

func (*NotifierRepository) Update

func (r *NotifierRepository) Update(ctx context.Context, userID uuid.UUID, id uuid.UUID, input NotifierUpdate) (NotifierOut, error)

type NotifierUpdate

type NotifierUpdate struct {
	Name     string  `json:"name"     validate:"required,min=1,max=255"`
	IsActive bool    `json:"isActive"`
	URL      *string `json:"url"      validate:"omitempty,shoutrrr"     extensions:"x-nullable"`
}

type PaginationResult

type PaginationResult[T any] struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
	Total    int `json:"total"`
	Items    []T `json:"items"`
}

type TokenRepository

type TokenRepository struct {
	// contains filtered or unexported fields
}

func (*TokenRepository) CreateToken

func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthTokenCreate, roles ...authroles.Role) (UserAuthToken, error)

CreateToken Creates a token for a user

func (*TokenRepository) DeleteAll

func (r *TokenRepository) DeleteAll(ctx context.Context) (int, error)

func (*TokenRepository) DeleteToken

func (r *TokenRepository) DeleteToken(ctx context.Context, token []byte) error

DeleteToken remove a single token from the database - equivalent to revoke or logout

func (*TokenRepository) GetRoles

func (r *TokenRepository) GetRoles(ctx context.Context, token string) (*set.Set[string], error)

func (*TokenRepository) GetUserFromToken

func (r *TokenRepository) GetUserFromToken(ctx context.Context, token []byte) (UserOut, error)

GetUserFromToken get's a user from a token

func (*TokenRepository) PurgeExpiredTokens

func (r *TokenRepository) PurgeExpiredTokens(ctx context.Context) (int, error)

PurgeExpiredTokens removes all expired tokens from the database

type TotalsByOrganizer

type TotalsByOrganizer struct {
	ID    uuid.UUID `json:"id"`
	Name  string    `json:"name"`
	Total float64   `json:"total"`
}

type TreeItem

type TreeItem struct {
	ID       uuid.UUID   `json:"id"`
	Name     string      `json:"name"`
	Type     string      `json:"type"`
	Children []*TreeItem `json:"children"`
}

func ConvertLocationsToTree

func ConvertLocationsToTree(locations []FlatTreeItem) []TreeItem

type TreeQuery

type TreeQuery struct {
	WithItems bool `json:"withItems" schema:"withItems"`
}

type UserAuthToken

type UserAuthToken struct {
	UserAuthTokenCreate
	CreatedAt time.Time `json:"createdAt"`
}

func (UserAuthToken) IsExpired

func (u UserAuthToken) IsExpired() bool

type UserAuthTokenCreate

type UserAuthTokenCreate struct {
	TokenHash []byte    `json:"token"`
	UserID    uuid.UUID `json:"userId"`
	ExpiresAt time.Time `json:"expiresAt"`
}

type UserCreate

type UserCreate struct {
	Name        string    `json:"name"`
	Email       string    `json:"email"`
	Password    string    `json:"password"`
	IsSuperuser bool      `json:"isSuperuser"`
	GroupID     uuid.UUID `json:"groupID"`
	IsOwner     bool      `json:"isOwner"`
}

UserCreate is the Data object contain the requirements of creating a user in the database. It should to create users from an API unless the user has rights to create SuperUsers. For regular user in data use the UserIn struct.

type UserOut

type UserOut struct {
	ID           uuid.UUID `json:"id"`
	Name         string    `json:"name"`
	Email        string    `json:"email"`
	IsSuperuser  bool      `json:"isSuperuser"`
	GroupID      uuid.UUID `json:"groupId"`
	GroupName    string    `json:"groupName"`
	PasswordHash string    `json:"-"`
	IsOwner      bool      `json:"isOwner"`
}

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

func (*UserRepository) ChangePassword

func (r *UserRepository) ChangePassword(ctx context.Context, UID uuid.UUID, pw string) error

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, usr UserCreate) (UserOut, error)

func (*UserRepository) Delete

func (r *UserRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*UserRepository) DeleteAll

func (r *UserRepository) DeleteAll(ctx context.Context) error

func (*UserRepository) GetAll

func (r *UserRepository) GetAll(ctx context.Context) ([]UserOut, error)

func (*UserRepository) GetOneEmail

func (r *UserRepository) GetOneEmail(ctx context.Context, email string) (UserOut, error)

func (*UserRepository) GetOneID

func (r *UserRepository) GetOneID(ctx context.Context, ID uuid.UUID) (UserOut, error)

func (*UserRepository) GetSuperusers

func (r *UserRepository) GetSuperusers(ctx context.Context) ([]*ent.User, error)

func (*UserRepository) Update

func (r *UserRepository) Update(ctx context.Context, ID uuid.UUID, data UserUpdate) error

type UserUpdate

type UserUpdate struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type ValueOverTime

type ValueOverTime struct {
	PriceAtStart float64              `json:"valueAtStart"`
	PriceAtEnd   float64              `json:"valueAtEnd"`
	Start        time.Time            `json:"start"`
	End          time.Time            `json:"end"`
	Entries      []ValueOverTimeEntry `json:"entries"`
}

type ValueOverTimeEntry

type ValueOverTimeEntry struct {
	Date  time.Time `json:"date"`
	Value float64   `json:"value"`
	Name  string    `json:"name"`
}

Jump to

Keyboard shortcuts

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