client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package client provides the public API for TaskKit.

Index

Constants

This section is empty.

Variables

View Source
var ErrCyclicDependency = engine.ErrCyclicDependency

ErrCyclicDependency is returned when adding a dependency would create a cycle.

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

ErrNotFound is returned when a requested task does not exist.

View Source
var ErrNothingToUndo = engine.ErrNothingToUndo

ErrNothingToUndo is returned when there is no operation to undo.

Functions

This section is empty.

Types

type Client

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

Client is the public API for TaskKit.

func NewClient

func NewClient(ctx context.Context, cfg *config.Config) (*Client, error)

NewClient initialises a Client using the provided configuration. Use config.Load or config.LoadFrom to obtain a Config.

func (*Client) Add

func (c *Client) Add(ctx context.Context, task *taskkit.Task) (*taskkit.Task, error)

Add creates a new pending task and returns it fully hydrated.

func (*Client) AddBlockedBy

func (c *Client) AddBlockedBy(ctx context.Context, taskID, dependsOnID string) error

AddBlockedBy records that taskID is blocked by dependsOnID. Returns ErrCyclicDependency if this would create a cycle, ErrNotFound if taskID does not exist.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying database connection.

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, id string) error

Complete marks a task as completed and frees its display ID.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, id string) error

Delete permanently removes a task and all associated records. Irreversible.

func (*Client) Get

func (c *Client) Get(ctx context.Context, filters ...filter.Filter) ([]*taskkit.Task, error)

Get returns tasks matching all provided filters. With no filters, all tasks are returned.

func (*Client) GetHistory

func (c *Client) GetHistory(ctx context.Context, taskID string) ([]taskkit.HistoryEntry, error)

GetHistory returns the full audit history for the task with the given ULID, grouped by operation and ordered oldest-first.

func (*Client) Import

func (c *Client) Import(ctx context.Context, tasks []*taskkit.Task) error

Import restores tasks from a previous export, preserving all IDs and status. Validation is skipped since the data is assumed to be from a prior valid state. Each task is imported atomically; if one fails the others are unaffected.

func (*Client) Modify

func (c *Client) Modify(ctx context.Context, id string, mods ...Modification) error

Modify applies one or more Modifications to a task in a single transaction.

func (*Client) Projects

func (c *Client) Projects(ctx context.Context) ([]*taskkit.ProjectSummary, error)

Projects returns a summary of all projects that have at least one task, sorted by project name.

func (*Client) RemoveBlockedBy

func (c *Client) RemoveBlockedBy(ctx context.Context, taskID, dependsOnID string) error

RemoveBlockedBy removes the dependency where taskID is blocked by dependsOnID. Returns ErrNotFound if the task does not exist.

func (*Client) Undo

func (c *Client) Undo(ctx context.Context) error

Undo reverses the last undoable operation.

func (*Client) UrgencyBreakdown

func (c *Client) UrgencyBreakdown(task *taskkit.Task) []taskkit.UrgencyComponent

UrgencyBreakdown returns the per-component urgency breakdown for a task.

type Modification

type Modification func(task *taskkit.Task) ([]engine.Mutation, error)

Modification is a function that, given the current task state, updates it in place and returns the engine mutations to apply. Multiple modifications can be passed to Modify and are applied atomically in a single transaction.

func AddBlockedBy

func AddBlockedBy(dependsOnID string) Modification

AddBlockedBy records that the task is blocked by dependsOnID. Returns ErrCyclicDependency if the dependency would create a cycle.

func AddTag

func AddTag(tag string) Modification

AddTag adds a tag to the task.

func RemoveBlockedBy

func RemoveBlockedBy(dependsOnID string) Modification

RemoveBlockedBy removes the dependency where the task is blocked by dependsOnID.

func RemoveTag

func RemoveTag(tag string) Modification

RemoveTag removes a tag from the task.

func SetDeadline

func SetDeadline(t *time.Time) Modification

SetDeadline changes the task deadline. Pass nil to clear it.

func SetDescription

func SetDescription(s string) Modification

SetDescription changes the task description.

func SetProject

func SetProject(project string) Modification

SetProject changes the task project.

func SetScheduled

func SetScheduled(t *time.Time) Modification

SetScheduled changes the task scheduled date. Pass nil to clear it.

func SetStatus

func SetStatus(s taskkit.Status) Modification

SetStatus changes the task status. If the new status closes the task (completed or removed), the display ID is also freed.

func SetWait

func SetWait(t *time.Time) Modification

SetWait changes the task wait date. Pass nil to clear it.

Jump to

Keyboard shortcuts

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