projects

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrProjectNotFound                   = "project not found"
	ErrClientNotFound                    = "client not found"
	ErrProjectExists                     = "project already exists"
	ErrProjectHasClients                 = "project has clients; deactivate clients to preserve history"
	ErrProjectArchiveBusy                = "project archive is in progress"
	ErrProjectDeleteConfirmationRequired = "project deletion requires its exact current name"
)

Variables

This section is empty.

Functions

func ValidateProjectForm

func ValidateProjectForm(ctx context.Context, form types.CreateProjectForm) error

func ValidateProjectPage

func ValidateProjectPage(ctx context.Context, query types.GetProjectPageInput) error

Types

type ArchiveContentDeleter

type ArchiveContentDeleter interface {
	Backend() string
	Delete(ctx context.Context, key string) error
}

ArchiveContentDeleter removes archive files after their rows are gone. Delete is idempotent for missing content and must target only this backend.

type Client

type Client struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

type PostgresProjectsService

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

func NewPostgresProjectsService

func NewPostgresProjectsService(pool *pgxpool.Pool) *PostgresProjectsService

func (*PostgresProjectsService) ClientBelongsToProject

func (p *PostgresProjectsService) ClientBelongsToProject(ctx context.Context, projectID, clientID string) (bool, error)

func (*PostgresProjectsService) CreateOrUpdateProject

func (p *PostgresProjectsService) CreateOrUpdateProject(ctx context.Context, form types.CreateProjectForm) (Project, error)

func (*PostgresProjectsService) CreateProject

func (p *PostgresProjectsService) CreateProject(ctx context.Context, name string, clients []string) (Project, error)

func (*PostgresProjectsService) DeleteProject

func (p *PostgresProjectsService) DeleteProject(ctx context.Context, id, confirmationName string) error

func (*PostgresProjectsService) GetProject

func (p *PostgresProjectsService) GetProject(ctx context.Context, id string) (Project, error)

func (*PostgresProjectsService) GetProjectPage

func (p *PostgresProjectsService) GetProjectPage(ctx context.Context, query types.GetProjectPageInput) ([]Project, int64, error)

func (*PostgresProjectsService) GetProjects

func (p *PostgresProjectsService) GetProjects(ctx context.Context) ([]Project, error)

func (*PostgresProjectsService) GetProjectsByIds

func (p *PostgresProjectsService) GetProjectsByIds(ctx context.Context, ids []string) ([]Project, error)

func (*PostgresProjectsService) ProjectExists

func (p *PostgresProjectsService) ProjectExists(ctx context.Context, projectID, clientID string) bool

func (*PostgresProjectsService) SearchProjects

func (p *PostgresProjectsService) SearchProjects(ctx context.Context, request SearchProjectsRequest) ([]Project, error)

func (*PostgresProjectsService) SetArchiveStore

func (p *PostgresProjectsService) SetArchiveStore(store ArchiveContentDeleter)

SetArchiveStore wires the store that holds ZIP content. Without it, a project that has archive rows cannot be deleted, because the files would be left behind.

func (*PostgresProjectsService) UpdateProject

func (p *PostgresProjectsService) UpdateProject(ctx context.Context, id uuid.UUID, name string, clients []string) (Project, error)

type Project

type Project struct {
	ID                 uuid.UUID `json:"id"`
	Name               string    `json:"name"`
	Clients            []Client  `json:"clients"`
	HasRetainedClients bool      `json:"hasRetainedClients"`
	TotalStorageSize   float64   `json:"totalStorageSize"`
}

func (Project) ClientNames

func (p Project) ClientNames() []string

func (*Project) ToCreateProjectForm

func (p *Project) ToCreateProjectForm() types.CreateProjectForm

type ProjectsService

type ProjectsService interface {
	CreateProject(ctx context.Context, name string, clients []string) (Project, error)
	UpdateProject(ctx context.Context, id uuid.UUID, name string, clients []string) (Project, error)
	CreateOrUpdateProject(ctx context.Context, project types.CreateProjectForm) (Project, error)
	GetProject(ctx context.Context, id string) (Project, error)
	GetProjects(ctx context.Context) ([]Project, error)
	GetProjectsByIds(ctx context.Context, ids []string) ([]Project, error)
	GetProjectPage(ctx context.Context, query types.GetProjectPageInput) ([]Project, int64, error)
	SearchProjects(ctx context.Context, request SearchProjectsRequest) ([]Project, error)
	DeleteProject(ctx context.Context, id, confirmationName string) error
	ProjectExists(ctx context.Context, projectID, clientID string) bool
	ClientBelongsToProject(ctx context.Context, projectID, clientID string) (bool, error)
}

type SearchProjectsRequest

type SearchProjectsRequest struct {
	Search string `json:"search" query:"search"`
	Page   int64  `json:"page" query:"page" default:"0" validate:"gte=0"`
	Size   int64  `json:"size" query:"size" default:"10" validate:"gte=1,lte=100"`
}

Jump to

Keyboard shortcuts

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