repository

package
v0.0.0-...-ee5b157 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package repository provides data access interfaces and implementations.

Package repository provides data access interfaces following SOLID principles.

Package repository provides data access interfaces following SOLID principles.

Package repository provides data access implementations for the Simple Easy Tasks application.

Package repository defines data access interfaces and implementations for the domain entities.

Index

Constants

View Source
const (
	SortOrderAsc  = "asc"
	SortOrderDesc = "desc"
)

SortOrder constants for task sorting

View Source
const (
	SortByCreated  = "created"
	SortByUpdated  = "updated"
	SortByTitle    = "title"
	SortByStatus   = "status"
	SortByPriority = "priority"
	SortByDueDate  = "due_date"
	SortByPosition = "position"
	SortByProgress = "progress"
)

Valid sort fields for tasks

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is a sentinel error for not found conditions

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error represents a "not found" condition. It uses errors.Is for proper error checking and falls back to legacy string comparison for compatibility with older error handling.

func NewPocketBasePasswordResetTokenRepository

func NewPocketBasePasswordResetTokenRepository(app core.App, secret string) domain.PasswordResetTokenRepository

NewPocketBasePasswordResetTokenRepository creates a new PocketBase password reset token repository.

func NewPocketBaseTokenBlacklistRepository

func NewPocketBaseTokenBlacklistRepository(app core.App) domain.TokenBlacklistRepository

NewPocketBaseTokenBlacklistRepository creates a new PocketBase token blacklist repository.

Types

type CommentCommandRepository

type CommentCommandRepository interface {
	// Create creates a new comment
	Create(ctx context.Context, comment *domain.Comment) error

	// Update updates an existing comment
	Update(ctx context.Context, comment *domain.Comment) error

	// Delete deletes a comment by ID
	Delete(ctx context.Context, id string) error

	// BulkDelete deletes multiple comments
	BulkDelete(ctx context.Context, ids []string) error

	// DeleteByTask deletes all comments for a task
	DeleteByTask(ctx context.Context, taskID string) error

	// SoftDelete marks a comment as deleted without removing it
	SoftDelete(ctx context.Context, id string) error

	// Restore restores a soft-deleted comment
	Restore(ctx context.Context, id string) error
}

CommentCommandRepository defines command operations for comments.

type CommentQueryRepository

type CommentQueryRepository interface {
	// GetByID retrieves a comment by its ID
	GetByID(ctx context.Context, id string) (*domain.Comment, error)

	// ListByTask retrieves comments for a specific task
	ListByTask(ctx context.Context, taskID string, offset, limit int) ([]*domain.Comment, error)

	// ListByAuthor retrieves comments by a specific author
	ListByAuthor(ctx context.Context, authorID string, offset, limit int) ([]*domain.Comment, error)

	// ListReplies retrieves replies to a specific comment
	ListReplies(ctx context.Context, parentID string) ([]*domain.Comment, error)

	// GetThread retrieves a comment thread (comment and its replies)
	GetThread(ctx context.Context, rootCommentID string) ([]*domain.Comment, error)

	// Count returns the total number of comments
	Count(ctx context.Context) (int, error)

	// CountByTask returns the number of comments for a task
	CountByTask(ctx context.Context, taskID string) (int, error)

	// CountByAuthor returns the number of comments by an author
	CountByAuthor(ctx context.Context, authorID string) (int, error)

	// ExistsByID checks if a comment exists by ID
	ExistsByID(ctx context.Context, id string) (bool, error)

	// Search searches comments by content
	Search(ctx context.Context, query string, taskID string, offset, limit int) ([]*domain.Comment, error)
}

CommentQueryRepository defines query operations for comments.

type CommentRepository

type CommentRepository interface {
	CommentQueryRepository
	CommentCommandRepository
}

CommentRepository defines the interface for comment data access operations.

func NewPocketBaseCommentRepository

func NewPocketBaseCommentRepository(app core.App) CommentRepository

NewPocketBaseCommentRepository creates a new PocketBase comment repository.

type GitHubAuthSessionRepository

type GitHubAuthSessionRepository interface {
	// Create creates a new GitHub auth session
	Create(ctx context.Context, session *domain.GitHubAuthSession) error

	// GetByUserID retrieves a GitHub auth session by user ID
	GetByUserID(ctx context.Context, userID string) (*domain.GitHubAuthSession, error)

	// DeleteByUserID deletes a GitHub auth session by user ID
	DeleteByUserID(ctx context.Context, userID string) error

	// DeleteExpired deletes all expired GitHub auth sessions
	DeleteExpired(ctx context.Context) error
}

GitHubAuthSessionRepository defines the interface for GitHub auth session data access.

func NewMemoryGitHubAuthSessionRepository

func NewMemoryGitHubAuthSessionRepository() GitHubAuthSessionRepository

NewMemoryGitHubAuthSessionRepository creates a new in-memory GitHub auth session repository.

type PocketBaseGitHubCommitLinkRepository

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

PocketBaseGitHubCommitLinkRepository implements GitHubCommitLinkRepository using PocketBase

func NewPocketBaseGitHubCommitLinkRepository

func NewPocketBaseGitHubCommitLinkRepository(app core.App) *PocketBaseGitHubCommitLinkRepository

NewPocketBaseGitHubCommitLinkRepository creates a new GitHub commit link repository instance

func (*PocketBaseGitHubCommitLinkRepository) Create

Create creates a new GitHub commit link in PocketBase

func (*PocketBaseGitHubCommitLinkRepository) Delete

Delete deletes a GitHub commit link from PocketBase

func (*PocketBaseGitHubCommitLinkRepository) GetByCommitSHA

func (r *PocketBaseGitHubCommitLinkRepository) GetByCommitSHA(_ context.Context, integrationID, commitSHA string) (*domain.GitHubCommitLink, error)

GetByCommitSHA retrieves a GitHub commit link by commit SHA from PocketBase

func (*PocketBaseGitHubCommitLinkRepository) GetByTaskID

GetByTaskID retrieves GitHub commit links by task ID from PocketBase

func (*PocketBaseGitHubCommitLinkRepository) ListByIntegration

func (r *PocketBaseGitHubCommitLinkRepository) ListByIntegration(_ context.Context, integrationID string) ([]*domain.GitHubCommitLink, error)

ListByIntegration retrieves GitHub commit links by integration ID from PocketBase

type PocketBaseGitHubIntegrationRepository

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

PocketBaseGitHubIntegrationRepository implements GitHubIntegrationRepository using PocketBase

func NewPocketBaseGitHubIntegrationRepository

func NewPocketBaseGitHubIntegrationRepository(app core.App) *PocketBaseGitHubIntegrationRepository

NewPocketBaseGitHubIntegrationRepository creates a new GitHub integration repository instance

func (*PocketBaseGitHubIntegrationRepository) Create

Create creates a new GitHub integration in PocketBase

func (*PocketBaseGitHubIntegrationRepository) Delete

Delete deletes a GitHub integration from PocketBase

func (*PocketBaseGitHubIntegrationRepository) GetByID

GetByID retrieves a GitHub integration by ID from PocketBase

func (*PocketBaseGitHubIntegrationRepository) GetByProjectID

GetByProjectID retrieves a GitHub integration by project ID from PocketBase

func (*PocketBaseGitHubIntegrationRepository) GetByRepoFullName

func (r *PocketBaseGitHubIntegrationRepository) GetByRepoFullName(
	_ context.Context,
	owner, name string,
) (*domain.GitHubIntegration, error)

GetByRepoFullName retrieves a GitHub integration by repository owner and name from PocketBase

func (*PocketBaseGitHubIntegrationRepository) List

List retrieves GitHub integrations for a user from PocketBase

func (*PocketBaseGitHubIntegrationRepository) Update

Update updates a GitHub integration in PocketBase

type PocketBaseGitHubIssueMappingRepository

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

PocketBaseGitHubIssueMappingRepository implements GitHubIssueMappingRepository using PocketBase

func NewPocketBaseGitHubIssueMappingRepository

func NewPocketBaseGitHubIssueMappingRepository(app core.App) *PocketBaseGitHubIssueMappingRepository

NewPocketBaseGitHubIssueMappingRepository creates a new GitHub issue mapping repository instance

func (*PocketBaseGitHubIssueMappingRepository) Create

Create creates a new GitHub issue mapping in PocketBase

func (*PocketBaseGitHubIssueMappingRepository) Delete

Delete deletes a GitHub issue mapping from PocketBase

func (*PocketBaseGitHubIssueMappingRepository) GetByIssueNumber

func (r *PocketBaseGitHubIssueMappingRepository) GetByIssueNumber(_ context.Context, integrationID string, issueNumber int) (*domain.GitHubIssueMapping, error)

GetByIssueNumber retrieves a GitHub issue mapping by issue number from PocketBase

func (*PocketBaseGitHubIssueMappingRepository) GetByTaskID

GetByTaskID retrieves a GitHub issue mapping by task ID from PocketBase

func (*PocketBaseGitHubIssueMappingRepository) ListByIntegration

func (r *PocketBaseGitHubIssueMappingRepository) ListByIntegration(_ context.Context, integrationID string) ([]*domain.GitHubIssueMapping, error)

ListByIntegration retrieves GitHub issue mappings by integration ID from PocketBase

func (*PocketBaseGitHubIssueMappingRepository) Update

Update updates a GitHub issue mapping in PocketBase

type PocketBaseGitHubOAuthStateRepository

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

PocketBaseGitHubOAuthStateRepository implements GitHubOAuthStateRepository using PocketBase

func NewPocketBaseGitHubOAuthStateRepository

func NewPocketBaseGitHubOAuthStateRepository(app core.App) *PocketBaseGitHubOAuthStateRepository

NewPocketBaseGitHubOAuthStateRepository creates a new GitHub OAuth state repository instance

func (*PocketBaseGitHubOAuthStateRepository) CleanupExpired

CleanupExpired removes expired GitHub OAuth states from PocketBase

func (*PocketBaseGitHubOAuthStateRepository) Create

Create creates a new GitHub OAuth state in PocketBase

func (*PocketBaseGitHubOAuthStateRepository) DeleteByState

DeleteByState deletes a GitHub OAuth state by state value from PocketBase

func (*PocketBaseGitHubOAuthStateRepository) GetByState

GetByState retrieves a GitHub OAuth state by state value from PocketBase

type PocketBaseGitHubPRMappingRepository

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

PocketBaseGitHubPRMappingRepository implements GitHubPRMappingRepository using PocketBase

func NewPocketBaseGitHubPRMappingRepository

func NewPocketBaseGitHubPRMappingRepository(app core.App) *PocketBaseGitHubPRMappingRepository

NewPocketBaseGitHubPRMappingRepository creates a new GitHub PR mapping repository instance

func (*PocketBaseGitHubPRMappingRepository) Create

Create creates a new GitHub PR mapping in PocketBase

func (*PocketBaseGitHubPRMappingRepository) Delete

Delete deletes a GitHub PR mapping from PocketBase

func (*PocketBaseGitHubPRMappingRepository) GetByPRNumber

func (r *PocketBaseGitHubPRMappingRepository) GetByPRNumber(_ context.Context, integrationID string, prNumber int) (*domain.GitHubPRMapping, error)

GetByPRNumber retrieves a GitHub PR mapping by PR number from PocketBase

func (*PocketBaseGitHubPRMappingRepository) GetByTaskID

GetByTaskID retrieves a GitHub PR mapping by task ID from PocketBase

func (*PocketBaseGitHubPRMappingRepository) ListByIntegration

func (r *PocketBaseGitHubPRMappingRepository) ListByIntegration(_ context.Context, integrationID string) ([]*domain.GitHubPRMapping, error)

ListByIntegration retrieves GitHub PR mappings by integration ID from PocketBase

func (*PocketBaseGitHubPRMappingRepository) Update

Update updates a GitHub PR mapping in PocketBase

type PocketBaseGitHubWebhookEventRepository

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

PocketBaseGitHubWebhookEventRepository implements GitHubWebhookEventRepository using PocketBase

func NewPocketBaseGitHubWebhookEventRepository

func NewPocketBaseGitHubWebhookEventRepository(app core.App) *PocketBaseGitHubWebhookEventRepository

NewPocketBaseGitHubWebhookEventRepository creates a new GitHub webhook event repository instance

func (*PocketBaseGitHubWebhookEventRepository) CleanupOld

CleanupOld removes old GitHub webhook events from PocketBase

func (*PocketBaseGitHubWebhookEventRepository) Create

Create creates a new GitHub webhook event in PocketBase

func (*PocketBaseGitHubWebhookEventRepository) GetByID

GetByID retrieves a GitHub webhook event by ID from PocketBase

func (*PocketBaseGitHubWebhookEventRepository) ListUnprocessed

ListUnprocessed retrieves unprocessed GitHub webhook events from PocketBase

func (*PocketBaseGitHubWebhookEventRepository) MarkError

MarkError marks a GitHub webhook event with an error message in PocketBase

func (*PocketBaseGitHubWebhookEventRepository) MarkProcessed

func (r *PocketBaseGitHubWebhookEventRepository) MarkProcessed(_ context.Context, id string, processedAt time.Time) error

MarkProcessed marks a GitHub webhook event as processed in PocketBase

type ProjectCommandRepository

type ProjectCommandRepository interface {
	// Create creates a new project.
	Create(ctx context.Context, project *domain.Project) error

	// Update updates an existing project.
	Update(ctx context.Context, project *domain.Project) error

	// Delete deletes a project by ID.
	Delete(ctx context.Context, id string) error
}

ProjectCommandRepository defines write operations for projects. Following Interface Segregation Principle.

type ProjectQueryRepository

type ProjectQueryRepository interface {
	// GetByID retrieves a project by ID.
	GetByID(ctx context.Context, id string) (*domain.Project, error)

	// GetBySlug retrieves a project by slug.
	GetBySlug(ctx context.Context, slug string) (*domain.Project, error)

	// ListByOwner retrieves projects owned by a specific user.
	ListByOwner(ctx context.Context, ownerID string, offset, limit int) ([]*domain.Project, error)

	// ListByMember retrieves projects where a user is a member.
	ListByMember(ctx context.Context, memberID string, offset, limit int) ([]*domain.Project, error)

	// List retrieves projects with pagination.
	List(ctx context.Context, offset, limit int) ([]*domain.Project, error)

	// Count returns the total number of projects.
	Count(ctx context.Context) (int, error)

	// ExistsBySlug checks if a project exists with the given slug.
	ExistsBySlug(ctx context.Context, slug string) (bool, error)

	// GetMemberProjects retrieves all projects where user has access.
	GetMemberProjects(ctx context.Context, userID string, offset, limit int) ([]*domain.Project, error)
}

ProjectQueryRepository defines read-only operations for project queries. Following Interface Segregation Principle.

type ProjectRepository

type ProjectRepository interface {
	// Create creates a new project.
	Create(ctx context.Context, project *domain.Project) error

	// GetByID retrieves a project by ID.
	GetByID(ctx context.Context, id string) (*domain.Project, error)

	// GetBySlug retrieves a project by slug.
	GetBySlug(ctx context.Context, slug string) (*domain.Project, error)

	// Update updates an existing project.
	Update(ctx context.Context, project *domain.Project) error

	// Delete deletes a project by ID.
	Delete(ctx context.Context, id string) error

	// ListByOwner retrieves projects owned by a specific user.
	ListByOwner(ctx context.Context, ownerID string, offset, limit int) ([]*domain.Project, error)

	// ListByMember retrieves projects where a user is a member.
	ListByMember(ctx context.Context, memberID string, offset, limit int) ([]*domain.Project, error)

	// List retrieves projects with pagination.
	List(ctx context.Context, offset, limit int) ([]*domain.Project, error)

	// Count returns the total number of projects.
	Count(ctx context.Context) (int, error)

	// ExistsBySlug checks if a project exists with the given slug.
	ExistsBySlug(ctx context.Context, slug string) (bool, error)

	// GetMemberProjects retrieves all projects where user has access.
	GetMemberProjects(ctx context.Context, userID string, offset, limit int) ([]*domain.Project, error)
}

ProjectRepository defines the interface for project data operations. Following Interface Segregation Principle.

func NewPocketBaseProjectRepository

func NewPocketBaseProjectRepository(app core.App) ProjectRepository

NewPocketBaseProjectRepository creates a new PocketBase project repository.

type TaskCommandRepository

type TaskCommandRepository interface {
	// Create creates a new task
	Create(ctx context.Context, task *domain.Task) error

	// Update updates an existing task
	Update(ctx context.Context, task *domain.Task) error

	// Delete deletes a task by ID
	Delete(ctx context.Context, id string) error

	// Move moves a task to a new status and position
	Move(ctx context.Context, taskID string, newStatus domain.TaskStatus, position int) error

	// BulkUpdate updates multiple tasks
	BulkUpdate(ctx context.Context, tasks []*domain.Task) error

	// BulkDelete deletes multiple tasks
	BulkDelete(ctx context.Context, ids []string) error

	// BulkUpdateStatus updates multiple tasks with the same status
	BulkUpdateStatus(ctx context.Context, taskIDs []string, newStatus domain.TaskStatus) error

	// ArchiveTask archives a task instead of deleting it
	ArchiveTask(ctx context.Context, id string) error

	// UnarchiveTask unarchives a task
	UnarchiveTask(ctx context.Context, id string) error
}

TaskCommandRepository defines command operations for tasks.

type TaskFilters

type TaskFilters struct {
	Status     []domain.TaskStatus   `json:"status,omitempty"`      // 24 bytes
	Priority   []domain.TaskPriority `json:"priority,omitempty"`    // 24 bytes
	Tags       []string              `json:"tags,omitempty"`        // 24 bytes
	Search     string                `json:"search,omitempty"`      // 16 bytes
	SortBy     string                `json:"sort_by,omitempty"`     // 16 bytes
	SortOrder  string                `json:"sort_order,omitempty"`  // 16 bytes
	DueBefore  *time.Time            `json:"due_before,omitempty"`  // 8 bytes
	DueAfter   *time.Time            `json:"due_after,omitempty"`   // 8 bytes
	AssigneeID *string               `json:"assignee_id,omitempty"` // 8 bytes
	ReporterID *string               `json:"reporter_id,omitempty"` // 8 bytes
	ParentID   *string               `json:"parent_id,omitempty"`   // 8 bytes
	Archived   *bool                 `json:"archived,omitempty"`    // 8 bytes
	HasParent  *bool                 `json:"has_parent,omitempty"`  // 8 bytes
	Limit      int                   `json:"limit,omitempty"`       // 8 bytes
	Offset     int                   `json:"offset,omitempty"`      // 8 bytes
}

TaskFilters provides advanced filtering options for task queries

type TaskQueryRepository

type TaskQueryRepository interface {
	// GetByID retrieves a task by its ID
	GetByID(ctx context.Context, id string) (*domain.Task, error)

	// GetByProject retrieves tasks for a specific project with advanced filtering
	GetByProject(ctx context.Context, projectID string, filters TaskFilters) ([]*domain.Task, error)

	// ListByProject retrieves tasks for a specific project (legacy method)
	ListByProject(ctx context.Context, projectID string, offset, limit int) ([]*domain.Task, error)

	// ListByAssignee retrieves tasks assigned to a specific user
	ListByAssignee(ctx context.Context, assigneeID string, offset, limit int) ([]*domain.Task, error)

	// ListByStatus retrieves tasks by status
	ListByStatus(ctx context.Context, status domain.TaskStatus, offset, limit int) ([]*domain.Task, error)

	// ListByCreator retrieves tasks created by a specific user
	ListByCreator(ctx context.Context, creatorID string, offset, limit int) ([]*domain.Task, error)

	// Search searches tasks by title, description or content
	Search(ctx context.Context, query string, projectID string, offset, limit int) ([]*domain.Task, error)

	// GetSubtasks retrieves subtasks for a parent task
	GetSubtasks(ctx context.Context, parentID string) ([]*domain.Task, error)

	// GetDependencies retrieves dependency tasks for a task
	GetDependencies(ctx context.Context, taskID string) ([]*domain.Task, error)

	// GetTasksByFilter retrieves tasks using advanced filters
	GetTasksByFilter(ctx context.Context, filters TaskFilters) ([]*domain.Task, error)

	// Count returns the total number of tasks matching criteria
	Count(ctx context.Context) (int, error)

	// CountByProject returns the number of tasks in a project
	CountByProject(ctx context.Context, projectID string) (int, error)

	// CountByAssignee returns the number of tasks assigned to a user
	CountByAssignee(ctx context.Context, assigneeID string) (int, error)

	// CountByStatus returns the number of tasks with a specific status
	CountByStatus(ctx context.Context, status domain.TaskStatus) (int, error)

	// ExistsByID checks if a task exists by ID
	ExistsByID(ctx context.Context, id string) (bool, error)
}

TaskQueryRepository defines query operations for tasks.

type TaskRepository

type TaskRepository interface {
	TaskQueryRepository
	TaskCommandRepository
}

TaskRepository defines the interface for task data access operations.

func NewPocketBaseTaskRepository

func NewPocketBaseTaskRepository(app core.App) TaskRepository

NewPocketBaseTaskRepository creates a new PocketBase task repository.

type TaskUpdate

type TaskUpdate struct {
	Fields map[string]interface{} `json:"fields"`
	TaskID string                 `json:"task_id"`
}

TaskUpdate represents a single task update operation for bulk updates

type UserCommandRepository

type UserCommandRepository interface {
	// Create creates a new user.
	Create(ctx context.Context, user *domain.User) error

	// Update updates an existing user.
	Update(ctx context.Context, user *domain.User) error

	// Delete deletes a user by ID.
	Delete(ctx context.Context, id string) error
}

UserCommandRepository defines write operations for users. Following Interface Segregation Principle.

type UserQueryRepository

type UserQueryRepository interface {
	// GetByID retrieves a user by ID.
	GetByID(ctx context.Context, id string) (*domain.User, error)

	// GetByEmail retrieves a user by email address.
	GetByEmail(ctx context.Context, email string) (*domain.User, error)

	// GetByUsername retrieves a user by username.
	GetByUsername(ctx context.Context, username string) (*domain.User, error)

	// List retrieves users with pagination.
	List(ctx context.Context, offset, limit int) ([]*domain.User, error)

	// Count returns the total number of users.
	Count(ctx context.Context) (int, error)

	// ExistsByEmail checks if a user exists with the given email.
	ExistsByEmail(ctx context.Context, email string) (bool, error)

	// ExistsByUsername checks if a user exists with the given username.
	ExistsByUsername(ctx context.Context, username string) (bool, error)
}

UserQueryRepository defines read-only operations for user queries. Following Interface Segregation Principle.

type UserRepository

type UserRepository interface {
	// Create creates a new user.
	Create(ctx context.Context, user *domain.User) error

	// GetByID retrieves a user by ID.
	GetByID(ctx context.Context, id string) (*domain.User, error)

	// GetByEmail retrieves a user by email address.
	GetByEmail(ctx context.Context, email string) (*domain.User, error)

	// GetByUsername retrieves a user by username.
	GetByUsername(ctx context.Context, username string) (*domain.User, error)

	// Update updates an existing user.
	Update(ctx context.Context, user *domain.User) error

	// Delete deletes a user by ID.
	Delete(ctx context.Context, id string) error

	// List retrieves users with pagination.
	List(ctx context.Context, offset, limit int) ([]*domain.User, error)

	// Count returns the total number of users.
	Count(ctx context.Context) (int, error)

	// ExistsByEmail checks if a user exists with the given email.
	ExistsByEmail(ctx context.Context, email string) (bool, error)

	// ExistsByUsername checks if a user exists with the given username.
	ExistsByUsername(ctx context.Context, username string) (bool, error)
}

UserRepository defines the interface for user data operations. Following Interface Segregation Principle.

func NewPocketBaseUserRepository

func NewPocketBaseUserRepository(app core.App) UserRepository

NewPocketBaseUserRepository creates a new PocketBase user repository.

Jump to

Keyboard shortcuts

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