1package repository
2
3import (
4 "context"
5
6 "github.com/bnema/dumber/internal/domain/entity"
7)
8
9// FavoriteRepository defines operations for bookmark persistence.
10type FavoriteRepository interface {
11 // Save creates or updates a favorite.
12 Save(ctx context.Context, fav *entity.Favorite) error
13
14 // FindByID retrieves a favorite by its ID.
15 FindByID(ctx context.Context, id entity.FavoriteID) (*entity.Favorite, error)
16
17 // FindByURL retrieves a favorite by its URL.
18 FindByURL(ctx context.Context, url string) (*entity.Favorite, error)
19
20 // GetAll retrieves all favorites.
21 GetAll(ctx context.Context) ([]*entity.Favorite, error)
22
23 // GetByFolder retrieves favorites in a specific folder.
24 // Pass nil for root-level favorites.
25 GetByFolder(ctx context.Context, folderID *entity.FolderID) ([]*entity.Favorite, error)
26
27 // GetByShortcut retrieves the favorite with the given shortcut key (1-9).
28 GetByShortcut(ctx context.Context, key int) (*entity.Favorite, error)
29
30 // UpdatePosition updates a favorite's position within its folder.
31 UpdatePosition(ctx context.Context, id entity.FavoriteID, position int) error
32
33 // SetFolder moves a favorite to a different folder.
34 SetFolder(ctx context.Context, id entity.FavoriteID, folderID *entity.FolderID) error
35
36 // SetShortcut assigns a keyboard shortcut (1-9) or nil to remove.
37 SetShortcut(ctx context.Context, id entity.FavoriteID, key *int) error
38
39 // Delete removes a favorite by ID.
40 Delete(ctx context.Context, id entity.FavoriteID) error
41}
42
43// FolderRepository defines operations for bookmark folder persistence.
44type FolderRepository interface {
45 // Save creates or updates a folder.
46 Save(ctx context.Context, folder *entity.Folder) error
47
48 // FindByID retrieves a folder by its ID.
49 FindByID(ctx context.Context, id entity.FolderID) (*entity.Folder, error)
50
51 // GetAll retrieves all folders.
52 GetAll(ctx context.Context) ([]*entity.Folder, error)
53
54 // GetChildren retrieves child folders of a parent.
55 // Pass nil for root-level folders.
56 GetChildren(ctx context.Context, parentID *entity.FolderID) ([]*entity.Folder, error)
57
58 // UpdatePosition updates a folder's position within its parent.
59 UpdatePosition(ctx context.Context, id entity.FolderID, position int) error
60
61 // Delete removes a folder by ID.
62 // Favorites in the folder should be moved to root.
63 Delete(ctx context.Context, id entity.FolderID) error
64}
65
66// TagRepository defines operations for tag persistence.
67type TagRepository interface {
68 // Save creates or updates a tag.
69 Save(ctx context.Context, tag *entity.Tag) error
70
71 // FindByID retrieves a tag by its ID.
72 FindByID(ctx context.Context, id entity.TagID) (*entity.Tag, error)
73
74 // FindByName retrieves a tag by its name.
75 FindByName(ctx context.Context, name string) (*entity.Tag, error)
76
77 // GetAll retrieves all tags.
78 GetAll(ctx context.Context) ([]*entity.Tag, error)
79
80 // AssignToFavorite associates a tag with a favorite.
81 AssignToFavorite(ctx context.Context, tagID entity.TagID, favID entity.FavoriteID) error
82
83 // RemoveFromFavorite removes a tag association from a favorite.
84 RemoveFromFavorite(ctx context.Context, tagID entity.TagID, favID entity.FavoriteID) error
85
86 // GetForFavorite retrieves all tags associated with a favorite.
87 GetForFavorite(ctx context.Context, favID entity.FavoriteID) ([]*entity.Tag, error)
88
89 // Delete removes a tag by ID.
90 Delete(ctx context.Context, id entity.TagID) error
91}