Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type CreateUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideCreateUseCase creates the use case for Wire
|
||||
func ProvideCreateUseCase(collectionRepo collection.Repository) *CreateUseCase {
|
||||
return &CreateUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute creates a new collection record
|
||||
func (uc *CreateUseCase) Execute(c *collection.Collection) error {
|
||||
return uc.collectionRepo.Create(c)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type DeleteUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideDeleteUseCase creates the use case for Wire
|
||||
func ProvideDeleteUseCase(collectionRepo collection.Repository) *DeleteUseCase {
|
||||
return &DeleteUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute deletes a collection by ID
|
||||
func (uc *DeleteUseCase) Execute(id string) error {
|
||||
return uc.collectionRepo.Delete(id)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/collection/get.go
Normal file
19
native/desktop/maplefile/internal/usecase/collection/get.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type GetUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideGetUseCase creates the use case for Wire
|
||||
func ProvideGetUseCase(collectionRepo collection.Repository) *GetUseCase {
|
||||
return &GetUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute retrieves a collection by ID
|
||||
func (uc *GetUseCase) Execute(id string) (*collection.Collection, error) {
|
||||
return uc.collectionRepo.Get(id)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/collection/list.go
Normal file
19
native/desktop/maplefile/internal/usecase/collection/list.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type ListUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideListUseCase creates the use case for Wire
|
||||
func ProvideListUseCase(collectionRepo collection.Repository) *ListUseCase {
|
||||
return &ListUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute returns all collections
|
||||
func (uc *ListUseCase) Execute() ([]*collection.Collection, error) {
|
||||
return uc.collectionRepo.List()
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type ListByParentUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideListByParentUseCase creates the use case for Wire
|
||||
func ProvideListByParentUseCase(collectionRepo collection.Repository) *ListByParentUseCase {
|
||||
return &ListByParentUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute returns all collections with a specific parent ID
|
||||
func (uc *ListByParentUseCase) Execute(parentID string) ([]*collection.Collection, error) {
|
||||
return uc.collectionRepo.ListByParent(parentID)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type ListRootUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideListRootUseCase creates the use case for Wire
|
||||
func ProvideListRootUseCase(collectionRepo collection.Repository) *ListRootUseCase {
|
||||
return &ListRootUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute returns all root-level collections (no parent)
|
||||
func (uc *ListRootUseCase) Execute() ([]*collection.Collection, error) {
|
||||
return uc.collectionRepo.ListRoot()
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package collection
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/collection"
|
||||
)
|
||||
|
||||
type UpdateUseCase struct {
|
||||
collectionRepo collection.Repository
|
||||
}
|
||||
|
||||
// ProvideUpdateUseCase creates the use case for Wire
|
||||
func ProvideUpdateUseCase(collectionRepo collection.Repository) *UpdateUseCase {
|
||||
return &UpdateUseCase{collectionRepo: collectionRepo}
|
||||
}
|
||||
|
||||
// Execute updates an existing collection record
|
||||
func (uc *UpdateUseCase) Execute(c *collection.Collection) error {
|
||||
return uc.collectionRepo.Update(c)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/file/create.go
Normal file
19
native/desktop/maplefile/internal/usecase/file/create.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type CreateUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideCreateUseCase creates the use case for Wire
|
||||
func ProvideCreateUseCase(fileRepo file.Repository) *CreateUseCase {
|
||||
return &CreateUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute creates a new file record
|
||||
func (uc *CreateUseCase) Execute(f *file.File) error {
|
||||
return uc.fileRepo.Create(f)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/file/delete.go
Normal file
19
native/desktop/maplefile/internal/usecase/file/delete.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type DeleteUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideDeleteUseCase creates the use case for Wire
|
||||
func ProvideDeleteUseCase(fileRepo file.Repository) *DeleteUseCase {
|
||||
return &DeleteUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute deletes a file by ID
|
||||
func (uc *DeleteUseCase) Execute(id string) error {
|
||||
return uc.fileRepo.Delete(id)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/file/get.go
Normal file
19
native/desktop/maplefile/internal/usecase/file/get.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type GetUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideGetUseCase creates the use case for Wire
|
||||
func ProvideGetUseCase(fileRepo file.Repository) *GetUseCase {
|
||||
return &GetUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute retrieves a file by ID
|
||||
func (uc *GetUseCase) Execute(id string) (*file.File, error) {
|
||||
return uc.fileRepo.Get(id)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/file/list.go
Normal file
19
native/desktop/maplefile/internal/usecase/file/list.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type ListUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideListUseCase creates the use case for Wire
|
||||
func ProvideListUseCase(fileRepo file.Repository) *ListUseCase {
|
||||
return &ListUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute returns all files
|
||||
func (uc *ListUseCase) Execute() ([]*file.File, error) {
|
||||
return uc.fileRepo.List()
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type ListByCollectionUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideListByCollectionUseCase creates the use case for Wire
|
||||
func ProvideListByCollectionUseCase(fileRepo file.Repository) *ListByCollectionUseCase {
|
||||
return &ListByCollectionUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute returns all files for a specific collection
|
||||
func (uc *ListByCollectionUseCase) Execute(collectionID string) ([]*file.File, error) {
|
||||
return uc.fileRepo.ListByCollection(collectionID)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type ListByStatusUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideListByStatusUseCase creates the use case for Wire
|
||||
func ProvideListByStatusUseCase(fileRepo file.Repository) *ListByStatusUseCase {
|
||||
return &ListByStatusUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute returns all files with a specific sync status
|
||||
func (uc *ListByStatusUseCase) Execute(status file.SyncStatus) ([]*file.File, error) {
|
||||
return uc.fileRepo.ListByStatus(status)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/file/update.go
Normal file
19
native/desktop/maplefile/internal/usecase/file/update.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/file"
|
||||
)
|
||||
|
||||
type UpdateUseCase struct {
|
||||
fileRepo file.Repository
|
||||
}
|
||||
|
||||
// ProvideUpdateUseCase creates the use case for Wire
|
||||
func ProvideUpdateUseCase(fileRepo file.Repository) *UpdateUseCase {
|
||||
return &UpdateUseCase{fileRepo: fileRepo}
|
||||
}
|
||||
|
||||
// Execute updates an existing file record
|
||||
func (uc *UpdateUseCase) Execute(f *file.File) error {
|
||||
return uc.fileRepo.Update(f)
|
||||
}
|
||||
33
native/desktop/maplefile/internal/usecase/session/create.go
Normal file
33
native/desktop/maplefile/internal/usecase/session/create.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type CreateUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideCreateUseCase creates the use case for Wire
|
||||
func ProvideCreateUseCase(sessionRepo session.Repository) *CreateUseCase {
|
||||
return &CreateUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute creates and stores a new session
|
||||
func (uc *CreateUseCase) Execute(
|
||||
userID, email, accessToken, refreshToken string,
|
||||
expiresIn time.Duration,
|
||||
) error {
|
||||
sess := &session.Session{
|
||||
UserID: userID,
|
||||
Email: email,
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: refreshToken,
|
||||
ExpiresAt: time.Now().Add(expiresIn),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
return uc.sessionRepo.Save(sess)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/session/delete.go
Normal file
19
native/desktop/maplefile/internal/usecase/session/delete.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type DeleteUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideDeleteUseCase creates the use case for Wire
|
||||
func ProvideDeleteUseCase(sessionRepo session.Repository) *DeleteUseCase {
|
||||
return &DeleteUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute deletes the current session
|
||||
func (uc *DeleteUseCase) Execute() error {
|
||||
return uc.sessionRepo.Delete()
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/session/getbyid.go
Normal file
19
native/desktop/maplefile/internal/usecase/session/getbyid.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type GetByIdUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideGetByIdUseCase creates the use case for Wire
|
||||
func ProvideGetByIdUseCase(sessionRepo session.Repository) *GetByIdUseCase {
|
||||
return &GetByIdUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute retrieves the current session
|
||||
func (uc *GetByIdUseCase) Execute() (*session.Session, error) {
|
||||
return uc.sessionRepo.Get()
|
||||
}
|
||||
22
native/desktop/maplefile/internal/usecase/session/save.go
Normal file
22
native/desktop/maplefile/internal/usecase/session/save.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type SaveUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideSaveUseCase creates the use case for Wire
|
||||
func ProvideSaveUseCase(sessionRepo session.Repository) *SaveUseCase {
|
||||
return &SaveUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute saves an existing session (for updates)
|
||||
func (uc *SaveUseCase) Execute(sess *session.Session) error {
|
||||
if sess == nil {
|
||||
return nil
|
||||
}
|
||||
return uc.sessionRepo.Save(sess)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/syncstate/get.go
Normal file
19
native/desktop/maplefile/internal/usecase/syncstate/get.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package syncstate
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/syncstate"
|
||||
)
|
||||
|
||||
type GetUseCase struct {
|
||||
syncStateRepo syncstate.Repository
|
||||
}
|
||||
|
||||
// ProvideGetUseCase creates the use case for Wire
|
||||
func ProvideGetUseCase(syncStateRepo syncstate.Repository) *GetUseCase {
|
||||
return &GetUseCase{syncStateRepo: syncStateRepo}
|
||||
}
|
||||
|
||||
// Execute retrieves the current sync state
|
||||
func (uc *GetUseCase) Execute() (*syncstate.SyncState, error) {
|
||||
return uc.syncStateRepo.Get()
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/syncstate/reset.go
Normal file
19
native/desktop/maplefile/internal/usecase/syncstate/reset.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package syncstate
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/syncstate"
|
||||
)
|
||||
|
||||
type ResetUseCase struct {
|
||||
syncStateRepo syncstate.Repository
|
||||
}
|
||||
|
||||
// ProvideResetUseCase creates the use case for Wire
|
||||
func ProvideResetUseCase(syncStateRepo syncstate.Repository) *ResetUseCase {
|
||||
return &ResetUseCase{syncStateRepo: syncStateRepo}
|
||||
}
|
||||
|
||||
// Execute resets the sync state for a fresh sync
|
||||
func (uc *ResetUseCase) Execute() error {
|
||||
return uc.syncStateRepo.Reset()
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/syncstate/save.go
Normal file
19
native/desktop/maplefile/internal/usecase/syncstate/save.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package syncstate
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/syncstate"
|
||||
)
|
||||
|
||||
type SaveUseCase struct {
|
||||
syncStateRepo syncstate.Repository
|
||||
}
|
||||
|
||||
// ProvideSaveUseCase creates the use case for Wire
|
||||
func ProvideSaveUseCase(syncStateRepo syncstate.Repository) *SaveUseCase {
|
||||
return &SaveUseCase{syncStateRepo: syncStateRepo}
|
||||
}
|
||||
|
||||
// Execute saves the sync state
|
||||
func (uc *SaveUseCase) Execute(state *syncstate.SyncState) error {
|
||||
return uc.syncStateRepo.Save(state)
|
||||
}
|
||||
34
native/desktop/maplefile/internal/usecase/user/create.go
Normal file
34
native/desktop/maplefile/internal/usecase/user/create.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/user"
|
||||
)
|
||||
|
||||
type CreateUseCase struct {
|
||||
userRepo user.Repository
|
||||
}
|
||||
|
||||
func ProvideCreateUseCase(userRepo user.Repository) *CreateUseCase {
|
||||
return &CreateUseCase{
|
||||
userRepo: userRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (uc *CreateUseCase) Execute(
|
||||
id, email, firstName, lastName string,
|
||||
storageQuotaBytes int64,
|
||||
) error {
|
||||
u := &user.User{
|
||||
ID: id,
|
||||
Email: email,
|
||||
FirstName: firstName,
|
||||
LastName: lastName,
|
||||
StorageQuotaBytes: storageQuotaBytes,
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
|
||||
return uc.userRepo.Save(u)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/user/getbyemail.go
Normal file
19
native/desktop/maplefile/internal/usecase/user/getbyemail.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/user"
|
||||
)
|
||||
|
||||
type GetByEmailUseCase struct {
|
||||
userRepo user.Repository
|
||||
}
|
||||
|
||||
func ProvideGetByEmailUseCase(userRepo user.Repository) *GetByEmailUseCase {
|
||||
return &GetByEmailUseCase{
|
||||
userRepo: userRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (uc *GetByEmailUseCase) Execute(email string) (*user.User, error) {
|
||||
return uc.userRepo.GetByEmail(email)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/user/getbyid.go
Normal file
19
native/desktop/maplefile/internal/usecase/user/getbyid.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/user"
|
||||
)
|
||||
|
||||
type GetByIdUseCase struct {
|
||||
userRepo user.Repository
|
||||
}
|
||||
|
||||
func ProvideGetByIdUseCase(userRepo user.Repository) *GetByIdUseCase {
|
||||
return &GetByIdUseCase{
|
||||
userRepo: userRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (uc *GetByIdUseCase) Execute(id string) (*user.User, error) {
|
||||
return uc.userRepo.GetByID(id)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue