libraries

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterListRoutes added in v0.1.0

func RegisterListRoutes(g *echo.Group, db *bun.DB)

RegisterListRoutes registers GET /libraries on a group the server has already configured with authentication and either libraries:read or users:write, since the user forms list libraries to assign access.

func RegisterRoutes added in v0.1.0

func RegisterRoutes(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware, opts ...RegisterRoutesOptions)

RegisterRoutes registers library routes on a group the server has already configured with authentication and the resource's read permission. The list lives in RegisterListRoutes because more roles may read it.

func RegisterUserRoutes added in v0.1.0

func RegisterUserRoutes(g *echo.Group, db *bun.DB)

RegisterUserRoutes registers GET /user/libraries on a group the server has already configured with authentication only. It lists the caller's accessible libraries as LibrarySummary rows.

Types

type CreateLibraryPayload

type CreateLibraryPayload struct {
	Name                  string   `json:"name" validate:"required,max=100"`
	OrganizeFileStructure *bool    `json:"organize_file_structure,omitempty"`
	CoverAspectRatio      string   `` /* 140-byte string literal not displayed */
	LibraryPaths          []string `json:"library_paths" validate:"required,min=1,max=50,dive"`
	TagNamespaces         []string `json:"tag_namespaces,omitempty" mod:"dive,trim" validate:"omitempty,max=20,dive,max=50"`
}

type LibrarySummary added in v0.1.0

type LibrarySummary struct {
	ID                    int    `json:"id"`
	Name                  string `json:"name"`
	CoverAspectRatio      string `json:"cover_aspect_ratio" tstype:"CoverAspectRatio"`
	OrganizeFileStructure bool   `json:"organize_file_structure"`
	// TagNamespaces group the library's tags on the tags page, the tag
	// filter, and the book page.
	TagNamespaces []string `json:"tag_namespaces"`
}

LibrarySummary is one library the caller can access, as listed by GET /user/libraries. It carries only what reader pages need (the library picker, breadcrumbs, cover aspect ratio, and the Merge and Move dialogs), not paths or timestamps, because the route requires no permission beyond authentication.

type ListLibrariesOptions

type ListLibrariesOptions struct {
	Limit      *int
	Offset     *int
	LibraryIDs []int // If non-nil, only return libraries with these IDs; an empty slice returns none
	// WithoutPaths skips loading LibraryPaths for callers that never return
	// them, such as the user-scoped library summaries.
	WithoutPaths bool
	// contains filtered or unexported fields
}

type ListLibrariesQuery

type ListLibrariesQuery struct {
	Limit  int `query:"limit" json:"limit,omitempty" default:"10" validate:"min=1,max=100"`
	Offset int `query:"offset" json:"offset,omitempty" validate:"min=0"`
}

type ListLibrariesResponse added in v0.0.47

type ListLibrariesResponse struct {
	Items []*models.Library `json:"items" tstype:"Library[]"`
	Total int               `json:"total"`
}

ListLibrariesResponse is the list-endpoint envelope.

type RegisterRoutesOptions added in v0.0.20

type RegisterRoutesOptions struct {
	// OnLibraryChanged is called after a library is created, has its paths
	// updated, or is deleted. Used by the monitor to refresh filesystem watches.
	OnLibraryChanged func()
}

RegisterRoutesOptions configures optional behaviors for library routes.

type RetrieveLibraryOptions

type RetrieveLibraryOptions struct {
	ID *int
}

type Service

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

func NewService

func NewService(db *bun.DB) *Service

func (*Service) CreateLibrary

func (svc *Service) CreateLibrary(ctx context.Context, library *models.Library) error

func (*Service) DeleteLibrary added in v0.0.37

func (svc *Service) DeleteLibrary(ctx context.Context, id int) error

DeleteLibrary hard-deletes a library and all of its DB-resident content. Files on disk are not touched. The operation runs in a single transaction:

  1. Cancel any pending/in-progress jobs scoped to this library.
  2. Purge FTS rows (books_fts, series_fts, persons_fts, genres_fts, tags_fts, publishers_fts) for this library. FTS purge must happen before the CASCADE so rows are still resolvable.
  3. Delete the library row; SQLite cascades the rest.

Returns errcodes.NotFound if the library does not exist.

func (*Service) ListLibraries

func (svc *Service) ListLibraries(ctx context.Context, opts ListLibrariesOptions) ([]*models.Library, error)

func (*Service) ListLibrariesWithTotal

func (svc *Service) ListLibrariesWithTotal(ctx context.Context, opts ListLibrariesOptions) ([]*models.Library, int, error)

func (*Service) RetrieveLibrary

func (svc *Service) RetrieveLibrary(ctx context.Context, opts RetrieveLibraryOptions) (*models.Library, error)

func (*Service) UpdateLibrary

func (svc *Service) UpdateLibrary(ctx context.Context, library *models.Library, opts UpdateLibraryOptions) error

type UpdateLibraryOptions

type UpdateLibraryOptions struct {
	Columns            []string
	UpdateLibraryPaths bool
}

type UpdateLibraryPayload

type UpdateLibraryPayload struct {
	Name                  *string  `json:"name,omitempty" validate:"omitempty,max=100"`
	OrganizeFileStructure *bool    `json:"organize_file_structure,omitempty"`
	CoverAspectRatio      *string  `` /* 151-byte string literal not displayed */
	LibraryPaths          []string `json:"library_paths,omitempty" validate:"omitempty,min=1,max=50,dive"`
	// TagNamespaces replaces the library's list when present; [] clears it.
	TagNamespaces []string `json:"tag_namespaces,omitempty" mod:"dive,trim" validate:"omitempty,max=20,dive,max=50"`
}

Jump to

Keyboard shortcuts

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