store

package
v0.1.847 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentConfigKeyLLM         = "llm"
	AgentConfigKeyProjectID   = "project_id"
	AgentConfigKeyPollSeconds = "poll_seconds"
	AgentConfigKeyVerbose     = "verbose"
)

Predefined agent config keys

View Source
const (
	StageDesign  = "design"
	StageDevelop = "develop"
	StageTest    = "test"
	StageDone    = "done"
)
View Source
const (
	StateIdle     = "idle"
	StateActive   = "active"
	StateSuccess  = "success"
	StateFail     = "fail"
	StateComplete = "complete"
)
View Source
const (
	DefaultListLimit    = 100
	DefaultHistoryLimit = 50
)
View Source
const (
	ProjectVisibilityPrivate = "private"
	ProjectVisibilityPublic  = "public"
)
View Source
const (
	ProjectRoleViewer = "viewer"
	ProjectRoleEditor = "editor"
	ProjectRoleOwner  = "owner"
)
View Source
const (
	LegacySchemaVersion  = 1
	CurrentSchemaVersion = 2
)
View Source
const (
	DefaultChatMaxConnections     = 2
	DefaultChatMaxDurationMinutes = 3
	DefaultChatEnabled            = true
)
View Source
const (
	TeamRoleMember = "member"
	TeamRoleOwner  = "owner"
)
View Source
const DefaultGuidanceStageKey = "default"
View Source
const SnapshotSchemaVersion = "ticket.schema.v1"

Variables

View Source
var (
	ErrInvalidCredentials = errors.New("invalid credentials")
	ErrUnauthorized       = errors.New("unauthorized")
	ErrForbidden          = errors.New("forbidden")
	ErrAdminRequired      = errors.New("user is not an admin")
	ErrAccountLocked      = errors.New("account locked, try again later")
)
View Source
var (
	ErrTeamNotFound       = errors.New("team not found")
	ErrTeamMemberNotFound = errors.New("team member not found")
)
View Source
var (
	ErrTicketNotFound    = errors.New("ticket not found")
	ErrTicketHasChildren = errors.New("ticket has child tickets")
	ErrTicketClosed      = errors.New("ticket is closed")
	ErrTicketArchived    = errors.New("ticket is archived")
)
View Source
var ErrDependencyNotFound = errors.New("dependency not found")
View Source
var ErrLabelNotFound = errors.New("label not found")
View Source
var ErrProjectMembershipNotFound = errors.New("project membership not found")
View Source
var ErrProjectNotFound = errors.New("project not found")
View Source
var ErrSdlcStageNotFound = errors.New("sdlc stage not found in sdlc")
View Source
var ErrTimeEntryNotFound = errors.New("time entry not found")

Functions

func AddHistoryEvent

func AddHistoryEvent(ctx context.Context, db *sql.DB, projectID int64, ticketID string, eventType string, payload any, createdBy string) error

func AddSdlcStageRole added in v0.1.842

func AddSdlcStageRole(ctx context.Context, db *sql.DB, sdlcID, stageID, roleID int64) error

func AddTicketLabel

func AddTicketLabel(ctx context.Context, db *sql.DB, ticketID string, labelID int64) error

func ChatEnabled

func ChatEnabled(ctx context.Context, db *sql.DB) (bool, error)

func CreateSession

func CreateSession(ctx context.Context, db *sql.DB, userID string) (string, error)

func DecryptEmail

func DecryptEmail(stored string) (string, error)

DecryptEmail decrypts an email address encrypted with EncryptEmail. If the value doesn't have the "enc:" prefix, it's returned as plaintext.

func DeleteAgent

func DeleteAgent(ctx context.Context, db *sql.DB, id string) error

func DeleteAgentConfig

func DeleteAgentConfig(ctx context.Context, db *sql.DB, agentID string, key string) error

func DeleteDependency

func DeleteDependency(ctx context.Context, db *sql.DB, projectID int64, ticketID, dependsOn string) error

func DeleteGoal

func DeleteGoal(ctx context.Context, db *sql.DB, id int64) error

func DeleteLabel

func DeleteLabel(ctx context.Context, db *sql.DB, id int64) error

func DeleteProject

func DeleteProject(ctx context.Context, db *sql.DB, id int64) error

DeleteProject removes a project and all associated data.

func DeleteRole

func DeleteRole(ctx context.Context, db *sql.DB, id int64) error

func DeleteSdlc added in v0.1.842

func DeleteSdlc(ctx context.Context, db *sql.DB, id int64) error

func DeleteSession

func DeleteSession(ctx context.Context, db *sql.DB, token string) error

func DeleteStory

func DeleteStory(ctx context.Context, db *sql.DB, storyID int64) error

func DeleteTeam

func DeleteTeam(ctx context.Context, db *sql.DB, id int64) error

func DeleteTicket

func DeleteTicket(ctx context.Context, db *sql.DB, id string) error

func DeleteTimeEntry

func DeleteTimeEntry(ctx context.Context, db *sql.DB, id int64) error

func DeleteUser

func DeleteUser(ctx context.Context, db *sql.DB, username string) error

func DetectSchemaVersion added in v0.1.842

func DetectSchemaVersion(path string) (int, error)

func EncryptEmail

func EncryptEmail(plaintext string) (string, error)

EncryptEmail encrypts an email address using AES-256-GCM. If no encryption key is configured, the plaintext is returned as-is.

func ExplainNoWork

func ExplainNoWork(ctx context.Context, db *sql.DB, projectID int64, username string) ([]string, error)

ExplainNoWork returns human-readable reasons why no ticket was available for automatic assignment in the given project.

func GetAgentConfigMap

func GetAgentConfigMap(ctx context.Context, db *sql.DB, agentID string) (map[string]string, error)

GetAgentConfigMap returns agent config as a map[string]string.

func GetAgentConfigUpdatedAt

func GetAgentConfigUpdatedAt(ctx context.Context, db *sql.DB, agentID string) (string, error)

GetAgentConfigUpdatedAt returns the most recent updated_at timestamp from agent_config. Returns empty string if no config exists.

func GetSdlcStageOrder added in v0.1.842

func GetSdlcStageOrder(ctx context.Context, db *sql.DB, stageID int64) (int, error)

GetSdlcStageOrder returns the sort_order for a sdlc stage by ID.

func HighestProjectRoleForTeams

func HighestProjectRoleForTeams(ctx context.Context, db *sql.DB, projectID int64, teamIDs []int64) (string, bool, error)

func ImportSnapshot

func ImportSnapshot(ctx context.Context, db *sql.DB, snapshot Snapshot) error

func Init

func Init(path, adminUsername, adminPassword string, seedFn ...SeedFunc) error

Init creates a new database at path with an admin user and a default project. The seedFn (if non-nil) is called to populate SDLCs and roles from embedded static files. If nil, no SDLCs are created and the project has no lifecycle.

func LinkStoryToTicket

func LinkStoryToTicket(ctx context.Context, db *sql.DB, storyID int64, ticketID string) error

func ListTicketsByLabel

func ListTicketsByLabel(ctx context.Context, db *sql.DB, labelID int64) ([]string, error)

func Open

func Open(path string) (*sql.DB, error)

func ParseLifecycleStatus

func ParseLifecycleStatus(raw string) (string, string, error)

func ProjectRoleForUser

func ProjectRoleForUser(ctx context.Context, db *sql.DB, projectID int64, userID string) (string, bool, error)

func PurgeExpiredSessions added in v0.1.733

func PurgeExpiredSessions(ctx context.Context, db *sql.DB) (int64, error)

PurgeExpiredSessions deletes sessions whose expires_at is in the past. Returns the number of rows deleted.

func PurgeOldHistory added in v0.1.733

func PurgeOldHistory(ctx context.Context, db *sql.DB, retentionDays int) (int64, error)

PurgeOldHistory deletes ticket_history events older than retentionDays days. Returns the number of rows deleted.

func ReapStaleAgents

func ReapStaleAgents(ctx context.Context, db *sql.DB, thresholdMinutes int) (int64, error)

ReapStaleAgents sets any non-idle agent to "idle" if its last_seen is older than the given threshold (in minutes). Returns the number of agents reaped.

func RegistrationEnabled

func RegistrationEnabled(ctx context.Context, db *sql.DB) (bool, error)

func RemoveProjectMember

func RemoveProjectMember(ctx context.Context, db *sql.DB, projectID int64, userID string) error

func RemoveProjectTeamMember

func RemoveProjectTeamMember(ctx context.Context, db *sql.DB, projectID, teamID int64) error

func RemoveSdlcStage added in v0.1.842

func RemoveSdlcStage(ctx context.Context, db *sql.DB, stageID int64) error

func RemoveSdlcStageRole added in v0.1.842

func RemoveSdlcStageRole(ctx context.Context, db *sql.DB, sdlcID, stageID, roleID int64) error

func RemoveTeamAgent

func RemoveTeamAgent(ctx context.Context, db *sql.DB, teamID int64, agentID string) error

func RemoveTeamMember

func RemoveTeamMember(ctx context.Context, db *sql.DB, teamID int64, userID string) error

func RemoveTicketLabel

func RemoveTicketLabel(ctx context.Context, db *sql.DB, ticketID string, labelID int64) error

func RenameProjectPrefix added in v0.1.733

func RenameProjectPrefix(ctx context.Context, db *sql.DB, projectID int64, newPrefix string) (int, error)

RenameProjectPrefix changes a project's prefix and re-keys every ticket in that project. All foreign-key references (parent_id, clone_of, dependencies, comments, history, labels, time entries, story links) are updated in a single transaction.

func RenderLifecycleStatus

func RenderLifecycleStatus(stage, state string) string

func ReorderSdlcStageRoles added in v0.1.842

func ReorderSdlcStageRoles(ctx context.Context, db *sql.DB, sdlcID, stageID int64, roleIDs []int64) error

func ReorderSdlcStages added in v0.1.842

func ReorderSdlcStages(ctx context.Context, db *sql.DB, sdlcID int64, orderedStageIDs []int64) error

func ResolveSdlcID added in v0.1.842

func ResolveSdlcID(ctx context.Context, db *sql.DB, ticket Ticket) *int64

ResolveSdlcID returns the effective sdlc ID for a ticket by walking: ticket.SdlcID → parent chain → project.SdlcID.

func SetAgentConfig

func SetAgentConfig(ctx context.Context, db *sql.DB, agentID string, key, value string) error

func SetChatEnabled

func SetChatEnabled(ctx context.Context, db *sql.DB, enabled bool) error

func SetChatLimitsConfig

func SetChatLimitsConfig(ctx context.Context, db *sql.DB, maxConnections, maxDurationMin int) error

func SetProjectDefaultDraft added in v0.1.842

func SetProjectDefaultDraft(ctx context.Context, db *sql.DB, projectID int64, draft bool) error

SetProjectDefaultDraft sets the default_draft flag on a project.

func SetRegistrationEnabled

func SetRegistrationEnabled(ctx context.Context, db *sql.DB, enabled bool) error

func SetUserEnabled

func SetUserEnabled(ctx context.Context, db *sql.DB, username string, enabled bool) error

func StoryIDForTicket

func StoryIDForTicket(ctx context.Context, db *sql.DB, ticketID string) (int64, bool, error)

func TeamDescendantIDs

func TeamDescendantIDs(ctx context.Context, db *sql.DB, teamID int64) ([]int64, error)

func TeamIDsForUserWithAncestors

func TeamIDsForUserWithAncestors(ctx context.Context, db *sql.DB, userID string) ([]int64, error)

func TeamRoleForUser

func TeamRoleForUser(ctx context.Context, db *sql.DB, teamID int64, userID string) (string, bool, error)

func TotalTimeForTicket

func TotalTimeForTicket(ctx context.Context, db *sql.DB, ticketID string) (int, error)

func UpgradeDatabase added in v0.1.842

func UpgradeDatabase(ctx context.Context, sourcePath, targetPath string) error

func ValidLifecycle

func ValidLifecycle(stage, state string) bool

func ValidStage

func ValidStage(stage string) bool

func ValidState

func ValidState(state string) bool

Types

type Agent

type Agent = User

Agent is a type alias for User. Agents are users with user_type='agent'.

func AuthenticateAgent

func AuthenticateAgent(ctx context.Context, db *sql.DB, agentID, plainPassword string) (Agent, error)

func CreateAgent

func CreateAgent(ctx context.Context, db *sql.DB, plainPassword string) (Agent, string, error)

func GetAgentByID

func GetAgentByID(ctx context.Context, db *sql.DB, id string) (Agent, error)

func GetAgentByUUID

func GetAgentByUUID(ctx context.Context, db *sql.DB, uuid string) (Agent, error)

func ListAgents

func ListAgents(ctx context.Context, db *sql.DB) ([]Agent, error)

func ListAgentsPage added in v0.1.842

func ListAgentsPage(ctx context.Context, db *sql.DB, limit, offset int) ([]Agent, error)

func SetAgentEnabled

func SetAgentEnabled(ctx context.Context, db *sql.DB, id string, enabled bool) (Agent, error)

func TouchAgent

func TouchAgent(ctx context.Context, db *sql.DB, id string, status string) (Agent, error)

func UpdateAgent

func UpdateAgent(ctx context.Context, db *sql.DB, id string, params AgentUpdateParams) (Agent, error)

type AgentConfigEntry

type AgentConfigEntry struct {
	UserID string `json:"user_id"`
	Key    string `json:"key"`
	Value  string `json:"value"`
}

func ListAgentConfig

func ListAgentConfig(ctx context.Context, db *sql.DB, agentID string) ([]AgentConfigEntry, error)

type AgentStatus

type AgentStatus struct {
	Agent       Agent   `json:"agent"`
	TicketKey   *string `json:"ticket_key,omitempty"`
	ProjectName string  `json:"project_name,omitempty"`
	SdlcName    string  `json:"sdlc_name,omitempty"`
	RoleTitle   string  `json:"role_title,omitempty"`
}

AgentStatus holds an agent and its currently assigned ticket (if any).

func ListAgentStatuses

func ListAgentStatuses(ctx context.Context, db *sql.DB) ([]AgentStatus, error)

ListAgentStatuses returns all agents with their currently assigned active ticket.

type AgentUpdateParams

type AgentUpdateParams struct {
	Password *string
}

type ChatLimits

type ChatLimits struct {
	MaxConnections int `json:"chat_max_connections"`
	MaxDurationMin int `json:"chat_max_duration_minutes"`
}

func ChatLimitsConfig

func ChatLimitsConfig(ctx context.Context, db *sql.DB) (ChatLimits, error)

type Comment

type Comment struct {
	ID        int64  `json:"-"`
	ItemID    string `json:"-"`
	UserID    string `json:"-"`
	Author    string `json:"author"`
	Comment   string `json:"-"`
	Text      string `json:"text"`
	CreatedAt string `json:"date"`
}

func AddComment

func AddComment(ctx context.Context, db *sql.DB, ticketID string, userID string, comment string) (Comment, error)

func ListComments

func ListComments(ctx context.Context, db *sql.DB, ticketID string) ([]Comment, error)

type CountSummary

type CountSummary struct {
	Users    int         `json:"users"`
	Projects int         `json:"projects,omitempty"`
	Types    []TypeCount `json:"types"`
}

func CountEverything

func CountEverything(ctx context.Context, db *sql.DB, projectID *int64) (CountSummary, error)

type Dependency

type Dependency struct {
	ID        int64  `json:"id"`
	ProjectID int64  `json:"project_id"`
	TicketID  string `json:"ticket_id"`
	DependsOn string `json:"depends_on"`
	CreatedBy string `json:"created_by"`
	CreatedAt string `json:"created_at"`
}

func AddDependency

func AddDependency(ctx context.Context, db *sql.DB, projectID int64, ticketID, dependsOn string, createdBy string) (Dependency, error)

func ListDependencies

func ListDependencies(ctx context.Context, db *sql.DB, ticketID string) ([]Dependency, error)

type Goal

type Goal struct {
	ID          int64  `json:"goal_id"`
	ProjectID   int64  `json:"project_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Notes       string `json:"notes"`
	ETA         string `json:"eta"`
	Priority    int    `json:"priority"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
}

func CreateGoal

func CreateGoal(ctx context.Context, db *sql.DB, projectID int64, title, description, notes, eta string, priority int) (Goal, error)

func GetGoal

func GetGoal(ctx context.Context, db *sql.DB, id int64) (Goal, error)

func ListGoals

func ListGoals(ctx context.Context, db *sql.DB, projectID int64) ([]Goal, error)

type GuidanceMap added in v0.1.842

type GuidanceMap map[string]string

func (GuidanceMap) Resolve added in v0.1.842

func (m GuidanceMap) Resolve(stage string) (string, bool)

type HistoryEvent

type HistoryEvent struct {
	ID        int64  `json:"id"`
	ProjectID int64  `json:"project_id"`
	TicketID  string `json:"ticket_id"`
	TicketKey string `json:"ticket_key,omitempty"`
	EventType string `json:"event_type"`
	Payload   string `json:"payload"`
	CreatedBy string `json:"created_by"`
	CreatedAt string `json:"created_at"`
}

func ListHistoryEvents

func ListHistoryEvents(ctx context.Context, db *sql.DB, ticketID string, limit, offset int) ([]HistoryEvent, error)

func ListProjectHistory

func ListProjectHistory(ctx context.Context, db *sql.DB, projectID int64, limit int) ([]HistoryEvent, error)

ListProjectHistory returns the most recent history events for all tickets in a project, ordered newest first, limited to limit rows.

func ListProjectHistoryFiltered added in v0.1.733

func ListProjectHistoryFiltered(ctx context.Context, db *sql.DB, projectID int64, limit int, filter HistoryFilter) ([]HistoryEvent, error)

ListProjectHistoryFiltered returns the most recent history events for all tickets in a project, applying optional actor filters.

type HistoryFilter added in v0.1.733

type HistoryFilter struct {
	UserID  string // filter by exact user_id (created_by)
	AgentID string // filter by agent user_id (created_by)
	TeamID  int64  // filter by team membership (team_members)
}

HistoryFilter holds optional filter criteria for history queries.

type Label

type Label struct {
	ID        int64  `json:"label_id"`
	ProjectID int64  `json:"project_id"`
	Name      string `json:"name"`
	Color     string `json:"color"`
	CreatedAt string `json:"created_at"`
}

func CreateLabel

func CreateLabel(ctx context.Context, db *sql.DB, projectID int64, name, color string) (Label, error)

func CreateLabelWithParams added in v0.1.842

func CreateLabelWithParams(ctx context.Context, db *sql.DB, params LabelCreateParams) (Label, error)

func GetLabel

func GetLabel(ctx context.Context, db *sql.DB, id int64) (Label, error)

func ListLabels

func ListLabels(ctx context.Context, db *sql.DB, projectID int64, limit, offset int) ([]Label, error)

func ListTicketLabels

func ListTicketLabels(ctx context.Context, db *sql.DB, ticketID string) ([]Label, error)

type LabelCreateParams added in v0.1.842

type LabelCreateParams struct {
	ID        *int64
	ProjectID int64
	Name      string
	Color     string
}

type Project

type Project struct {
	ID                 int64       `json:"project_id"`
	Prefix             string      `json:"prefix"`
	Title              string      `json:"title"`
	Description        string      `json:"description"`
	AcceptanceCriteria string      `json:"acceptance_criteria"`
	DORMap             GuidanceMap `json:"dor_map,omitempty"`
	DODMap             GuidanceMap `json:"dod_map,omitempty"`
	ACMap              GuidanceMap `json:"ac_map,omitempty"`
	GitRepository      string      `json:"git_repository"`
	Notes              string      `json:"notes"`
	Status             string      `json:"status"`
	Visibility         string      `json:"visibility"`
	DefaultDraft       bool        `json:"default_draft"`
	CreatedBy          string      `json:"created_by"`
	CreatedAt          string      `json:"created_at"`
	UpdatedAt          string      `json:"updated_at"`
	SdlcID             *int64      `json:"sdlc_id,omitempty"`
}

func CreateProject

func CreateProject(ctx context.Context, db *sql.DB, title, description, acceptanceCriteria string, createdBy string) (Project, error)

func CreateProjectWithParams

func CreateProjectWithParams(ctx context.Context, db *sql.DB, params ProjectCreateParams) (Project, error)

func GetProject

func GetProject(ctx context.Context, db *sql.DB, rawID string) (Project, error)

func GetProjectByID

func GetProjectByID(ctx context.Context, db *sql.DB, id int64) (Project, error)

func ListProjects

func ListProjects(ctx context.Context, db *sql.DB, limit int) ([]Project, error)

func ListProjectsVisibleToUser

func ListProjectsVisibleToUser(ctx context.Context, db *sql.DB, user User) ([]Project, error)

func SetProjectStatus

func SetProjectStatus(ctx context.Context, db *sql.DB, id int64, enabled bool) (Project, error)

func UpdateProject

func UpdateProject(ctx context.Context, db *sql.DB, id int64, title, description, acceptanceCriteria string) (Project, error)

func UpdateProjectWithParams

func UpdateProjectWithParams(ctx context.Context, db *sql.DB, id int64, params ProjectUpdateParams) (Project, error)

func (Project) ResolveGuidance added in v0.1.842

func (p Project) ResolveGuidance(stage string) ResolvedGuidance

type ProjectCreateParams

type ProjectCreateParams struct {
	ID                 *int64
	Prefix             string
	Title              string
	Description        string
	AcceptanceCriteria string
	DORMap             GuidanceMap
	DODMap             GuidanceMap
	ACMap              GuidanceMap
	GitRepository      string
	Notes              string
	Visibility         string
	CreatedBy          string
	SdlcID             *int64
}

type ProjectMember

type ProjectMember struct {
	ProjectID int64  `json:"project_id"`
	UserID    string `json:"user_id"`
	Username  string `json:"username"`
	Role      string `json:"role"`
}

func AddProjectMember

func AddProjectMember(ctx context.Context, db *sql.DB, projectID int64, userID string, role string) (ProjectMember, error)

func GetProjectMember

func GetProjectMember(ctx context.Context, db *sql.DB, projectID int64, userID string) (ProjectMember, error)

func ListProjectMembers

func ListProjectMembers(ctx context.Context, db *sql.DB, projectID int64) ([]ProjectMember, error)

type ProjectTeamMember

type ProjectTeamMember struct {
	ProjectID int64  `json:"project_id"`
	TeamID    int64  `json:"team_id"`
	TeamName  string `json:"team_name"`
	Role      string `json:"role"`
}

func AddProjectTeamMember

func AddProjectTeamMember(ctx context.Context, db *sql.DB, projectID, teamID int64, role string) (ProjectTeamMember, error)

func ListProjectTeamMembers

func ListProjectTeamMembers(ctx context.Context, db *sql.DB, projectID int64) ([]ProjectTeamMember, error)

type ProjectUpdateParams

type ProjectUpdateParams struct {
	Title              string
	Description        string
	AcceptanceCriteria string
	DORMap             GuidanceMap
	DODMap             GuidanceMap
	ACMap              GuidanceMap
	GitRepository      string
	Notes              string
	Status             string
	Visibility         string
	SdlcID             *int64
}

type ResolvedGuidance added in v0.1.842

type ResolvedGuidance struct {
	DOR    string `json:"dor,omitempty"`
	DOD    string `json:"dod,omitempty"`
	AC     string `json:"ac,omitempty"`
	HasDOR bool   `json:"-"`
	HasDOD bool   `json:"-"`
	HasAC  bool   `json:"-"`
}

type Role

type Role struct {
	ID                 int64       `json:"role_id"`
	SdlcID             *int64      `json:"sdlc_id,omitempty"`
	Title              string      `json:"title"`
	Description        string      `json:"description"`
	AcceptanceCriteria string      `json:"acceptance_criteria"`
	DORMap             GuidanceMap `json:"dor_map,omitempty"`
	DODMap             GuidanceMap `json:"dod_map,omitempty"`
	ACMap              GuidanceMap `json:"ac_map,omitempty"`
	CreatedAt          string      `json:"created_at"`
	UpdatedAt          string      `json:"updated_at"`
}

func CreateRole

func CreateRole(ctx context.Context, db *sql.DB, sdlcID *int64, title, description, ac string) (Role, error)

func CreateRoleWithParams added in v0.1.842

func CreateRoleWithParams(ctx context.Context, db *sql.DB, params RoleCreateParams) (Role, error)

func GetRoleByID

func GetRoleByID(ctx context.Context, db *sql.DB, id int64) (Role, error)

func GetRoleByTitle

func GetRoleByTitle(ctx context.Context, db *sql.DB, title string) (Role, error)

func ListRoles

func ListRoles(ctx context.Context, db *sql.DB, limit int) ([]Role, error)

func ListRolesBySdlc added in v0.1.842

func ListRolesBySdlc(ctx context.Context, db *sql.DB, sdlcID int64) ([]Role, error)

func ListSdlcStageRoles added in v0.1.842

func ListSdlcStageRoles(ctx context.Context, db *sql.DB, sdlcID, stageID int64) ([]Role, error)

func UpdateRole

func UpdateRole(ctx context.Context, db *sql.DB, id int64, title, description, ac string) (Role, error)

func UpdateRoleWithParams added in v0.1.842

func UpdateRoleWithParams(ctx context.Context, db *sql.DB, id int64, params RoleUpdateParams) (Role, error)

func (Role) ResolveGuidance added in v0.1.842

func (r Role) ResolveGuidance(stage string) ResolvedGuidance

type RoleCreateParams added in v0.1.842

type RoleCreateParams struct {
	ID                 *int64
	SdlcID             *int64
	Title              string
	Description        string
	AcceptanceCriteria string
	DORMap             GuidanceMap
	DODMap             GuidanceMap
	ACMap              GuidanceMap
}

type RoleUpdateParams added in v0.1.842

type RoleUpdateParams struct {
	Title              string
	Description        string
	AcceptanceCriteria string
	DORMap             GuidanceMap
	DODMap             GuidanceMap
	ACMap              GuidanceMap
}

type SchemaVersionError added in v0.1.842

type SchemaVersionError struct {
	Path          string
	Found         int
	Current       int
	UpgradeNeeded bool
}

func (*SchemaVersionError) Error added in v0.1.842

func (e *SchemaVersionError) Error() string

type Sdlc added in v0.1.842

type Sdlc struct {
	ID          int64  `json:"sdlc_id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
}

func CreateSdlc added in v0.1.842

func CreateSdlc(ctx context.Context, db *sql.DB, name, description string) (Sdlc, error)

func CreateSdlcWithParams added in v0.1.842

func CreateSdlcWithParams(ctx context.Context, db *sql.DB, id *int64, name, description string) (Sdlc, error)

func ImportSdlc added in v0.1.842

func ImportSdlc(ctx context.Context, db *sql.DB, export SdlcExport) (Sdlc, error)

func ListSdlcs added in v0.1.842

func ListSdlcs(ctx context.Context, db *sql.DB, limit, offset int) ([]Sdlc, error)

type SdlcExport added in v0.1.842

type SdlcExport struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Stages      []SdlcStageExport `json:"stages"`
}

func ExportSdlc added in v0.1.842

func ExportSdlc(ctx context.Context, db *sql.DB, id int64) (SdlcExport, error)

type SdlcStage added in v0.1.842

type SdlcStage struct {
	ID                 int64  `json:"sdlc_stage_id"`
	SdlcID             int64  `json:"sdlc_id"`
	StageName          string `json:"stage_name"`
	Description        string `json:"description"`
	AcceptanceCriteria string `json:"acceptance_criteria"`
	DefinitionOfReady  string `json:"definition_of_ready"`
	DefinitionOfDone   string `json:"definition_of_done"`
	SortOrder          int    `json:"sort_order"`
	Roles              []Role `json:"roles,omitempty"`
	CreatedAt          string `json:"created_at"`
	UpdatedAt          string `json:"updated_at"`
}

func AddSdlcStage added in v0.1.842

func AddSdlcStage(ctx context.Context, db *sql.DB, sdlcID int64, stageName, description, acceptanceCriteria string, sortOrder int) (SdlcStage, error)

func AddSdlcStageWithDefinitions added in v0.1.842

func AddSdlcStageWithDefinitions(ctx context.Context, db *sql.DB, sdlcID int64, stageName, wow, dor, dod string, sortOrder int) (SdlcStage, error)

func GetSdlcStage added in v0.1.842

func GetSdlcStage(ctx context.Context, db *sql.DB, stageID int64) (SdlcStage, error)

func ListSdlcStages added in v0.1.842

func ListSdlcStages(ctx context.Context, db *sql.DB, sdlcID int64) ([]SdlcStage, error)

func UpdateSdlcStage added in v0.1.842

func UpdateSdlcStage(ctx context.Context, db *sql.DB, stageID int64, name, description, acceptanceCriteria string) (SdlcStage, error)

func UpdateSdlcStageWithDefinitions added in v0.1.842

func UpdateSdlcStageWithDefinitions(ctx context.Context, db *sql.DB, stageID int64, name, wow, dor, dod string) (SdlcStage, error)

type SdlcStageExport added in v0.1.842

type SdlcStageExport struct {
	StageName   string   `json:"stage_name"`
	Description string   `json:"description"`
	Roles       []string `json:"roles,omitempty"`
	SortOrder   int      `json:"sort_order"`
}

type SdlcWithStages added in v0.1.842

type SdlcWithStages struct {
	Sdlc
	Stages []SdlcStage `json:"stages"`
}

func GetSdlc added in v0.1.842

func GetSdlc(ctx context.Context, db *sql.DB, id int64) (SdlcWithStages, error)

type SeedFunc added in v0.1.842

type SeedFunc func(ctx context.Context, db *sql.DB) error

SeedFunc is called during Init to seed the database with SDLCs and roles. It receives the opened database and should create at least one SDLC. The first SDLC found after seeding is assigned to the default project.

type Snapshot

type Snapshot struct {
	SchemaVersion string                   `json:"schema_version"`
	ExportedAt    string                   `json:"exported_at"`
	Signature     string                   `json:"signature,omitempty"`
	Tables        map[string]SnapshotTable `json:"tables"`
}

func ExportSnapshot

func ExportSnapshot(ctx context.Context, db *sql.DB) (Snapshot, error)

type SnapshotTable

type SnapshotTable struct {
	Columns []string `json:"columns"`
	Rows    [][]any  `json:"rows"`
}

type Story

type Story struct {
	ID          int64  `json:"story_id"`
	ProjectID   int64  `json:"project_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Status      string `json:"status"`
	CreatedBy   string `json:"created_by"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
}

func CreateStory

func CreateStory(ctx context.Context, db *sql.DB, projectID int64, title, description string, createdBy string) (Story, error)

func CreateStoryWithParams added in v0.1.842

func CreateStoryWithParams(ctx context.Context, db *sql.DB, params StoryCreateParams) (Story, error)

func GetStory

func GetStory(ctx context.Context, db *sql.DB, storyID int64) (Story, error)

func ListStoriesByProject

func ListStoriesByProject(ctx context.Context, db *sql.DB, projectID int64, limit, offset int) ([]Story, error)

func UpdateStory

func UpdateStory(ctx context.Context, db *sql.DB, storyID int64, title, description string) (Story, error)

func UpdateStoryStatus

func UpdateStoryStatus(ctx context.Context, db *sql.DB, storyID int64, status string) (Story, error)

type StoryCreateParams added in v0.1.842

type StoryCreateParams struct {
	ID          *int64
	ProjectID   int64
	Title       string
	Description string
	CreatedBy   string
}

type Team

type Team struct {
	ID           int64  `json:"team_id"`
	Name         string `json:"name"`
	ParentTeamID *int64 `json:"parent_team_id"`
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
}

func CreateTeam

func CreateTeam(ctx context.Context, db *sql.DB, name string, parentTeamID *int64) (Team, error)

func CreateTeamWithParams added in v0.1.842

func CreateTeamWithParams(ctx context.Context, db *sql.DB, params TeamCreateParams) (Team, error)

func GetTeamByID

func GetTeamByID(ctx context.Context, db *sql.DB, id int64) (Team, error)

func ListTeams

func ListTeams(ctx context.Context, db *sql.DB, limit int) ([]Team, error)

func UpdateTeam

func UpdateTeam(ctx context.Context, db *sql.DB, id int64, name string, parentTeamID *int64) (Team, error)

type TeamAgent

type TeamAgent struct {
	TeamID    int64  `json:"team_id"`
	AgentID   string `json:"agent_id"`
	AgentUUID string `json:"agent_uuid"`
	Enabled   bool   `json:"enabled"`
	Status    string `json:"status"`
}

func AddTeamAgent

func AddTeamAgent(ctx context.Context, db *sql.DB, teamID int64, agentID string) (TeamAgent, error)

func ListTeamAgents

func ListTeamAgents(ctx context.Context, db *sql.DB, teamID int64) ([]TeamAgent, error)

type TeamCreateParams added in v0.1.842

type TeamCreateParams struct {
	ID           *int64
	Name         string
	ParentTeamID *int64
}

type TeamMember

type TeamMember struct {
	TeamID   int64  `json:"team_id"`
	UserID   string `json:"user_id"`
	Username string `json:"username"`
	Role     string `json:"role"`
	JobTitle string `json:"job_title"`
}

func AddTeamMember

func AddTeamMember(ctx context.Context, db *sql.DB, teamID int64, userID string, role, jobTitle string) (TeamMember, error)

func GetTeamMember

func GetTeamMember(ctx context.Context, db *sql.DB, teamID int64, userID string) (TeamMember, error)

func ListTeamMembers

func ListTeamMembers(ctx context.Context, db *sql.DB, teamID int64) ([]TeamMember, error)

type Ticket

type Ticket struct {
	ID                  string      `json:"ticket_id"`
	ProjectID           int64       `json:"project_id"`
	ParentID            *string     `json:"parent_id,omitempty"`
	CloneOf             *string     `json:"clone_of,omitempty"`
	Type                string      `json:"type"`
	Title               string      `json:"title"`
	Description         string      `json:"description"`
	AcceptanceCriteria  string      `json:"acceptance_criteria"`
	DORMap              GuidanceMap `json:"dor_map,omitempty"`
	DODMap              GuidanceMap `json:"dod_map,omitempty"`
	ACMap               GuidanceMap `json:"ac_map,omitempty"`
	GitRepository       string      `json:"git_repository"`
	GitBranch           string      `json:"git_branch"`
	SdlcID              *int64      `json:"sdlc_id,omitempty"`
	SdlcStageID         *int64      `json:"sdlc_stage_id,omitempty"`
	RoleID              *int64      `json:"role_id,omitempty"`
	Stage               string      `json:"stage"`
	State               string      `json:"state"`
	Status              string      `json:"status"`
	Priority            int         `json:"priority"`
	Order               int         `json:"order"`
	EstimateEffort      int         `json:"estimate_effort"`
	EstimateComplete    string      `json:"estimate_complete,omitempty"`
	HealthScore         int         `json:"health_score"`
	Assignee            string      `json:"assignee"`
	Author              string      `json:"author"`
	Comments            []Comment   `json:"comments,omitempty"`
	Draft               bool        `json:"draft"`
	Complete            bool        `json:"complete"`
	Archived            bool        `json:"archived"`
	Deleted             bool        `json:"deleted"`
	PreviousSdlcStageID *int64      `json:"previous_sdlc_stage_id,omitempty"`
	PreviousRoleID      *int64      `json:"previous_role_id,omitempty"`
	CreatedBy           string      `json:"created_by"`
	CreatedAt           string      `json:"created_at"`
	UpdatedAt           string      `json:"updated_at"`
}

func CloneTicket

func CloneTicket(ctx context.Context, db *sql.DB, id string, author string, createdBy string) (Ticket, error)

func CreateTicket

func CreateTicket(ctx context.Context, db *sql.DB, params TicketCreateParams) (Ticket, error)

func CurrentAssignedTicketForUser

func CurrentAssignedTicketForUser(ctx context.Context, db *sql.DB, projectID int64, username string) (Ticket, bool, error)

func GetTicket

func GetTicket(ctx context.Context, db *sql.DB, id string) (Ticket, error)

func GetTicketByProject

func GetTicketByProject(ctx context.Context, db *sql.DB, projectID int64, id string) (Ticket, error)

func GetTicketByRef

func GetTicketByRef(ctx context.Context, db *sql.DB, raw string) (Ticket, error)

func ListTicketParents

func ListTicketParents(ctx context.Context, db *sql.DB, id string) ([]Ticket, error)

func ListTickets

func ListTickets(ctx context.Context, db *sql.DB, params TicketListParams) ([]Ticket, error)

func ListTicketsByProject

func ListTicketsByProject(ctx context.Context, db *sql.DB, projectID int64) ([]Ticket, error)

func NextTicket added in v0.1.842

func NextTicket(ctx context.Context, db *sql.DB, id string, actorUsername, actorID string) (Ticket, error)

NextTicket advances a ticket to the next role within its stage, or to the first role of the next stage if it's at the last role. Requires state=success.

func PreviousTicket added in v0.1.842

func PreviousTicket(ctx context.Context, db *sql.DB, id string, actorUsername, actorID string) (Ticket, error)

PreviousTicket moves a ticket back to the previous role or stage. Requires state=fail.

func RequestTicket

func RequestTicket(ctx context.Context, db *sql.DB, params TicketRequestParams) (Ticket, string, error)

func SearchTickets

func SearchTickets(ctx context.Context, db *sql.DB, projectID int64, query string) ([]Ticket, error)

func SetTicketArchived

func SetTicketArchived(ctx context.Context, db *sql.DB, id string, archived bool, actorUsername string, actorID string) (Ticket, error)

func SetTicketComplete added in v0.1.842

func SetTicketComplete(ctx context.Context, db *sql.DB, id string, complete bool, actorUsername string, actorID string) (Ticket, error)

func SetTicketDraft added in v0.1.842

func SetTicketDraft(ctx context.Context, db *sql.DB, id string, draft bool, actorUsername string, actorID string) (Ticket, error)

func SetTicketHealth

func SetTicketHealth(ctx context.Context, db *sql.DB, id string, score int) (Ticket, error)

func SetTicketSdlc added in v0.1.842

func SetTicketSdlc(ctx context.Context, db *sql.DB, ticketID string, sdlcID int64) (Ticket, error)

SetTicketSdlc sets an explicit sdlc on a ticket, resetting the sdlc stage to the first stage of the new sdlc.

func UnsetTicketSdlc added in v0.1.842

func UnsetTicketSdlc(ctx context.Context, db *sql.DB, ticketID string) (Ticket, error)

UnsetTicketSdlc clears the explicit sdlc on a ticket, falling back to the inherited sdlc and resetting the stage accordingly.

func UpdateTicket

func UpdateTicket(ctx context.Context, db *sql.DB, id string, params TicketUpdateParams) (Ticket, error)

func (Ticket) ResolveGuidance added in v0.1.842

func (t Ticket) ResolveGuidance(stage string) ResolvedGuidance

type TicketContext

type TicketContext struct {
	Project *Project        `json:"project,omitempty"`
	Parents []Ticket        `json:"parents,omitempty"`
	Sdlc    *SdlcWithStages `json:"sdlc,omitempty"`
	Role    *Role           `json:"role,omitempty"`
}

TicketContext holds a ticket and all surrounding context needed to work on it.

func EnrichTicketContext

func EnrichTicketContext(ctx context.Context, db *sql.DB, ticket Ticket) TicketContext

EnrichTicketContext gathers the project, parent chain, sdlc, and current-stage role for a ticket. Missing data is silently skipped.

type TicketCreateParams

type TicketCreateParams struct {
	ProjectID          int64
	ParentID           *string
	CloneOf            *string
	SdlcID             *int64
	Type               string
	Title              string
	Description        string
	AcceptanceCriteria string
	DORMap             GuidanceMap
	DODMap             GuidanceMap
	ACMap              GuidanceMap
	GitRepository      string
	GitBranch          string
	Priority           int
	Order              int
	EstimateEffort     int
	EstimateComplete   string
	Assignee           string
	Author             string
	State              string
	CreatedBy          string
}

type TicketHistoryEvent

type TicketHistoryEvent = HistoryEvent

type TicketListParams

type TicketListParams struct {
	ProjectID       int64
	Type            string
	Stage           string
	State           string
	Status          string
	Search          string
	Assignee        string
	Limit           int
	Offset          int
	IncludeArchived bool
}

type TicketRequestParams

type TicketRequestParams struct {
	ProjectID int64
	TicketID  *string
	TicketRef string
	Username  string
	UserID    string
	DryRun    bool
}

type TicketUpdateParams

type TicketUpdateParams struct {
	Title              string
	Description        string
	AcceptanceCriteria string
	DORMap             GuidanceMap
	DODMap             GuidanceMap
	ACMap              GuidanceMap
	GitRepository      string
	GitBranch          string
	ParentID           *string
	Assignee           string
	Stage              string
	State              string
	Priority           int
	Order              int
	EstimateEffort     int
	EstimateComplete   string
	UpdatedBy          string
	ActorUsername      string
	ActorRole          string
	Type               string // if non-empty, update the ticket type
}

type TimeEntry

type TimeEntry struct {
	ID        int64  `json:"time_entry_id"`
	TicketID  string `json:"ticket_id"`
	UserID    string `json:"user_id"`
	Minutes   int    `json:"minutes"`
	Note      string `json:"note"`
	CreatedAt string `json:"created_at"`
}

func GetTimeEntry

func GetTimeEntry(ctx context.Context, db *sql.DB, id int64) (TimeEntry, error)

func ListTimeEntries

func ListTimeEntries(ctx context.Context, db *sql.DB, ticketID string) ([]TimeEntry, error)

func LogTime

func LogTime(ctx context.Context, db *sql.DB, ticketID string, userID string, minutes int, note string) (TimeEntry, error)

type TypeCount

type TypeCount struct {
	Type     string         `json:"type"`
	Total    int            `json:"total"`
	Statuses map[string]int `json:"statuses"`
}

type User

type User struct {
	ID               string `json:"user_id"`
	Username         string `json:"username"`
	Email            string `json:"email"`
	EmailConfirmedAt string `json:"email_confirmed_at,omitempty"`
	Role             string `json:"role"`
	DisplayName      string `json:"display_name"`
	Enabled          bool   `json:"enabled"`
	CreatedAt        string `json:"created_at"`
	UserType         string `json:"user_type"`
	Description      string `json:"description,omitempty"`
	Status           string `json:"status,omitempty"`
	LastSeen         string `json:"last_seen,omitempty"`
	UpdatedAt        string `json:"updated_at,omitempty"`
}

func AuthenticateUser

func AuthenticateUser(ctx context.Context, db *sql.DB, username, plainPassword string) (User, error)

func CreateUser

func CreateUser(ctx context.Context, db *sql.DB, username, plainPassword, role string) (User, error)

func GetUserByID

func GetUserByID(ctx context.Context, db *sql.DB, id string) (User, error)

func GetUserByToken

func GetUserByToken(ctx context.Context, db *sql.DB, token string) (User, error)

func GetUserByUsername

func GetUserByUsername(ctx context.Context, db *sql.DB, username string) (User, error)

func ListUsers

func ListUsers(ctx context.Context, db *sql.DB, limit int) ([]User, error)

func RegisterUser

func RegisterUser(ctx context.Context, db *sql.DB, username, plainPassword string) (User, error)

func ResetUserPassword

func ResetUserPassword(ctx context.Context, db *sql.DB, username, newPlainPassword string) (User, error)

ResetUserPassword changes the password and invalidates all sessions.

Jump to

Keyboard shortcuts

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