Documentation
¶
Index ¶
- Constants
- func RegisterRoutesWithGroup(g *echo.Group, db *bun.DB, _ *auth.Middleware)
- type AddBooksOptions
- type AddBooksPayload
- type CheckVisibilityQuery
- type CheckVisibilityResponse
- type CreateListOptions
- type CreateListPayload
- type CreateShareOptions
- type CreateSharePayload
- type ListBooksOptions
- type ListBooksQuery
- type ListListBooksResponse
- type ListListsOptions
- type ListListsQuery
- type ListListsResponse
- type ListResponse
- type ListTemplate
- type MoveBookPositionPayload
- type RemoveBooksOptions
- type RemoveBooksPayload
- type ReorderBooksOptions
- type ReorderBooksPayload
- type RetrieveListOptions
- type RetrieveListResponse
- type Service
- func (svc *Service) AddBooks(ctx context.Context, opts AddBooksOptions) error
- func (svc *Service) CanEdit(ctx context.Context, listID, userID int) (bool, error)
- func (svc *Service) CanManage(ctx context.Context, listID, userID int) (bool, error)
- func (svc *Service) CanView(ctx context.Context, listID, userID int) (bool, error)
- func (svc *Service) CheckBookVisibility(ctx context.Context, listID int, targetUserLibraryIDs []int) (visible, total int, err error)
- func (svc *Service) CreateList(ctx context.Context, opts CreateListOptions) (*models.List, error)
- func (svc *Service) CreateShare(ctx context.Context, opts CreateShareOptions) (*models.ListShare, error)
- func (svc *Service) DeleteList(ctx context.Context, listID int) error
- func (svc *Service) DeleteShare(ctx context.Context, shareID int) error
- func (svc *Service) GetBookLists(ctx context.Context, bookID, userID int) ([]*models.List, error)
- func (svc *Service) GetListBookCount(ctx context.Context, listID int, libraryIDs []int) (int, error)
- func (svc *Service) HasShare(ctx context.Context, listID, userID int) (bool, error)
- func (svc *Service) IsOwner(ctx context.Context, listID, userID int) (bool, error)
- func (svc *Service) ListBooks(ctx context.Context, opts ListBooksOptions) ([]*models.ListBook, error)
- func (svc *Service) ListBooksWithTotal(ctx context.Context, opts ListBooksOptions) ([]*models.ListBook, int, error)
- func (svc *Service) ListLists(ctx context.Context, opts ListListsOptions) ([]*models.List, error)
- func (svc *Service) ListListsWithTotal(ctx context.Context, opts ListListsOptions) ([]*models.List, int, error)
- func (svc *Service) ListShares(ctx context.Context, listID int) ([]*models.ListShare, error)
- func (svc *Service) MoveBookToPosition(ctx context.Context, listID, bookID, position int) error
- func (svc *Service) RemoveBooks(ctx context.Context, opts RemoveBooksOptions) error
- func (svc *Service) ReorderBooks(ctx context.Context, opts ReorderBooksOptions) error
- func (svc *Service) RetrieveList(ctx context.Context, opts RetrieveListOptions) (*models.List, error)
- func (svc *Service) UpdateBookListMemberships(ctx context.Context, bookID, userID int, listIDs []int) error
- func (svc *Service) UpdateList(ctx context.Context, list *models.List, opts UpdateListOptions) error
- func (svc *Service) UpdateShare(ctx context.Context, shareID int, permission string) error
- type UpdateBookListsPayload
- type UpdateListOptions
- type UpdateListPayload
- type UpdateSharePayload
Constants ¶
const (
//tygo:emit export type ListResponsePermission = "owner" | "manager" | "editor" | "viewer";
PermissionOwner = "owner"
)
PermissionOwner is the synthetic permission the list/retrieve handlers return for a list's owner. The persisted share grants are the ListPermission values (viewer/editor/manager); "owner" is computed per request, never stored.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutesWithGroup ¶
RegisterRoutesWithGroup registers lists routes on a pre-configured group.
Types ¶
type AddBooksOptions ¶
type AddBooksPayload ¶
type AddBooksPayload struct {
BookIDs []int `json:"book_ids" validate:"required,min=1,max=500,dive,min=1"`
}
type CheckVisibilityQuery ¶
type CheckVisibilityQuery struct {
UserID int `query:"user_id" json:"user_id" validate:"required,min=1" tstype:"number"`
}
type CheckVisibilityResponse ¶ added in v0.0.47
CheckVisibilityResponse reports how many of a list's books a target user can see given their library access.
type CreateListOptions ¶
type CreateListPayload ¶
type CreateListPayload struct {
Name string `json:"name" validate:"required,min=1,max=200"`
Description *string `json:"description,omitempty" validate:"omitempty,max=2000" tstype:"string"`
IsOrdered bool `json:"is_ordered"`
DefaultSort *string `` /* 152-byte string literal not displayed */
}
Payloads for create/update endpoints.
type CreateShareOptions ¶
type CreateShareOptions struct {
}
type CreateSharePayload ¶
type CreateSharePayload struct {
}
type ListBooksOptions ¶
type ListBooksQuery ¶
type ListListBooksResponse ¶ added in v0.0.47
type ListListBooksResponse struct {
Items []*models.ListBook `json:"items" tstype:"ListBook[]"`
Total int `json:"total"`
}
ListListBooksResponse is the books-in-list envelope. Items are ListBook rows (each carrying its Book) so the frontend can read cover cache keys.
type ListListsOptions ¶
type ListListsQuery ¶
type ListListsQuery struct {
Limit int `query:"limit" json:"limit,omitempty" default:"50" validate:"min=1,max=100"`
Offset int `query:"offset" json:"offset,omitempty" validate:"min=0"`
}
Query params for list endpoints.
type ListListsResponse ¶ added in v0.0.47
type ListListsResponse struct {
Items []ListResponse `json:"items"`
Total int `json:"total"`
}
ListListsResponse is the list-endpoint envelope.
type ListResponse ¶ added in v0.0.47
type ListResponse struct {
models.List `tstype:",extends"`
BookCount int `json:"book_count"`
Permission string `json:"permission" tstype:"ListResponsePermission"`
}
ListResponse is a single list augmented with the requesting user's effective permission and the list's book count. It embeds the List model by value so tygo emits `extends List` and the wire format stays byte-identical.
type ListTemplate ¶ added in v0.0.47
type ListTemplate struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
IsOrdered bool `json:"is_ordered"`
DefaultSort string `json:"default_sort" tstype:"ListSort"`
}
ListTemplate is a built-in list template offered by the templates endpoint.
type MoveBookPositionPayload ¶
type MoveBookPositionPayload struct {
Position int `json:"position" validate:"required,min=1"`
}
type RemoveBooksOptions ¶
type RemoveBooksPayload ¶
type RemoveBooksPayload struct {
BookIDs []int `json:"book_ids" validate:"required,min=1,max=500,dive,min=1"`
}
type ReorderBooksOptions ¶
type ReorderBooksPayload ¶
type ReorderBooksPayload struct {
BookIDs []int `json:"book_ids" validate:"required,min=1,max=500,dive,min=1"`
}
type RetrieveListOptions ¶
type RetrieveListOptions struct {
ID *int
}
type RetrieveListResponse ¶ added in v0.0.47
type RetrieveListResponse struct {
models.List `tstype:",extends"`
BookCount int `json:"book_count"`
Permission string `json:"permission" tstype:"ListResponsePermission"`
}
RetrieveListResponse is the single-list API response. It mirrors ListResponse: the List model fields are flattened in, plus book_count and permission.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AddBooks ¶
func (svc *Service) AddBooks(ctx context.Context, opts AddBooksOptions) error
func (*Service) CheckBookVisibility ¶
func (svc *Service) CheckBookVisibility(ctx context.Context, listID int, targetUserLibraryIDs []int) (visible, total int, err error)
CheckBookVisibility returns counts of visible/total books for a user.
func (*Service) CreateList ¶
func (*Service) CreateShare ¶
func (*Service) DeleteShare ¶
func (*Service) GetBookLists ¶
GetBookLists returns lists that contain a specific book (for the user).
func (*Service) GetListBookCount ¶
func (svc *Service) GetListBookCount(ctx context.Context, listID int, libraryIDs []int) (int, error)
GetListBookCount returns the number of books in a list visible to the user.
func (*Service) ListBooksWithTotal ¶
func (*Service) ListListsWithTotal ¶
func (*Service) ListShares ¶
func (*Service) MoveBookToPosition ¶
MoveBookToPosition moves a book to a specific position within an ordered list.
func (*Service) RemoveBooks ¶
func (svc *Service) RemoveBooks(ctx context.Context, opts RemoveBooksOptions) error
func (*Service) ReorderBooks ¶
func (svc *Service) ReorderBooks(ctx context.Context, opts ReorderBooksOptions) error
func (*Service) RetrieveList ¶
func (*Service) UpdateBookListMemberships ¶
func (svc *Service) UpdateBookListMemberships(ctx context.Context, bookID, userID int, listIDs []int) error
UpdateBookListMemberships replaces which lists a book belongs to. Only modifies lists the user can edit.
func (*Service) UpdateList ¶
type UpdateBookListsPayload ¶
type UpdateBookListsPayload struct {
ListIDs []int `json:"list_ids" validate:"dive,min=1"`
}
type UpdateListOptions ¶
type UpdateListOptions struct {
Columns []string
}
type UpdateListPayload ¶
type UpdateListPayload struct {
Name *string `json:"name,omitempty" validate:"omitempty,min=1,max=200" tstype:"string"`
Description *string `json:"description,omitempty" validate:"omitempty,max=2000" tstype:"string"`
IsOrdered *bool `json:"is_ordered,omitempty" tstype:"boolean"`
DefaultSort *string `` /* 152-byte string literal not displayed */
}
type UpdateSharePayload ¶
type UpdateSharePayload struct {
}