Documentation
¶
Overview ¶
Package things3 provides a Go library for Things 3 on macOS with read-only database access and full URL Scheme support for creating and updating tasks.
Features ¶
This package offers two main capabilities:
- Read-only access to the Things 3 SQLite database for querying tasks, projects, areas, and tags
- Full Things URL Scheme support for creating, updating, and navigating to items
Getting Started ¶
All operations go through a single Client:
client, err := things3.NewClient()
if err != nil {
log.Fatal(err)
}
defer client.Close()
// Convenience methods
inbox, _ := client.Inbox(ctx)
today, _ := client.Today(ctx)
todos, _ := client.Todos(ctx)
Fluent Query Builder ¶
For complex queries, use the type-safe fluent query builder:
tasks, _ := client.Tasks().
Type().Todo().
Status().Incomplete().
StartDate().Future().
All(ctx)
URL Scheme ¶
Create and update items via Things URL Scheme:
// Create a new to-do
client.AddTodo().
Title("Buy groceries").
When(things3.Today()).
Tags("shopping").
Execute(ctx)
// Update existing items (auth token managed automatically)
client.UpdateTodo("uuid").Completed(true).Execute(ctx)
Configuration ¶
Configure the client with functional options:
client, _ := things3.NewClient(things3.WithDatabasePath("/path/to/main.sqlite"))
client, _ := things3.NewClient(things3.WithPrintSQL(true))
Database Discovery ¶
The database path is discovered in the following order:
- Custom path provided via WithDatabasePath option
- THINGSDB environment variable
- Auto-discovery of default Things 3 database location
Type System ¶
The package uses integer-based enums that map directly to database values:
- TaskType: TaskTypeTodo (0), TaskTypeProject (1), TaskTypeHeading (2)
- Status: StatusIncomplete (0), StatusCanceled (2), StatusCompleted (3)
- StartBucket: StartInbox (0), StartAnytime (1), StartSomeday (2)
References ¶
For the official Things URL Scheme documentation, see: https://culturedcode.com/things/support/articles/2803573/
Index ¶
- Variables
- func ApplyWhen[T WhenScheduler[T]](b T, when string) T
- func DaysAgo(n int) time.Time
- func Headings(headings ...string) string
- func MonthsAgo(n int) time.Time
- func Today() time.Time
- func Tomorrow() time.Time
- func WeeksAgo(n int) time.Time
- func YearsAgo(n int) time.Time
- type Area
- type AreaQueryBuilder
- type AreaQueryExecutor
- type AuthBatchCreator
- type BatchCreator
- type BatchProjectConfigurator
- type BatchTodoConfigurator
- type ChecklistItem
- type Client
- func (c *Client) AddProject() ProjectAdder
- func (c *Client) AddTodo() TodoAdder
- func (c *Client) Anytime(ctx context.Context) ([]Task, error)
- func (c *Client) Areas() AreaQueryBuilder
- func (c *Client) AuthBatch() AuthBatchCreator
- func (c *Client) Batch() BatchCreator
- func (c *Client) Canceled(ctx context.Context) ([]Task, error)
- func (c *Client) ChecklistItems(ctx context.Context, todoUUID string) ([]ChecklistItem, error)
- func (c *Client) Close() error
- func (c *Client) Completed(ctx context.Context) ([]Task, error)
- func (c *Client) CreatedWithin(ctx context.Context, since time.Time) ([]Task, error)
- func (c *Client) Deadlines(ctx context.Context) ([]Task, error)
- func (c *Client) Get(ctx context.Context, uuid string) (any, error)
- func (c *Client) Inbox(ctx context.Context) ([]Task, error)
- func (c *Client) Logbook(ctx context.Context) ([]Task, error)
- func (c *Client) Projects(ctx context.Context) ([]Task, error)
- func (c *Client) Search(ctx context.Context, query string) ([]Task, error)
- func (c *Client) Show(ctx context.Context, uuid string) error
- func (c *Client) ShowBuilder() ShowNavigator
- func (c *Client) ShowList(ctx context.Context, list ListID) error
- func (c *Client) ShowSearch(ctx context.Context, query string) error
- func (c *Client) Someday(ctx context.Context) ([]Task, error)
- func (c *Client) Tags() TagQueryBuilder
- func (c *Client) Tasks() TaskQueryBuilder
- func (c *Client) Today(ctx context.Context) ([]Task, error)
- func (c *Client) Todos(ctx context.Context) ([]Task, error)
- func (c *Client) Token(ctx context.Context) (string, error)
- func (c *Client) Trash(ctx context.Context) ([]Task, error)
- func (c *Client) Upcoming(ctx context.Context) ([]Task, error)
- func (c *Client) UpdateProject(id string) ProjectUpdater
- func (c *Client) UpdateTodo(id string) TodoUpdater
- type ClientOption
- type Command
- type DateFilterBuilder
- type JSONItem
- type JSONItemType
- type JSONOperation
- type ListID
- type ProjectAdder
- type ProjectUpdater
- type ShowNavigator
- type StartBucket
- type StartFilterBuilder
- type Status
- type StatusFilterBuilder
- type Tag
- type TagQueryBuilder
- type TagQueryExecutor
- type Task
- type TaskQueryBuilder
- type TaskQueryExecutor
- type TaskRelationFilter
- type TaskStateFilter
- type TaskTimeFilter
- type TaskType
- type TodoAdder
- type TodoUpdater
- type TypeFilterBuilder
- type URLBuilder
- type WhenScheduler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDatabaseNotFound is returned when the Things database cannot be located. ErrDatabaseNotFound = errors.New("things3: database not found") // ErrDatabaseVersionTooOld is returned when the database version is not supported. ErrDatabaseVersionTooOld = errors.New("things3: database version too old (requires things3 version > 21)") )
Database Errors
var ( // ErrTaskNotFound is returned when a task with the specified UUID does not exist. ErrTaskNotFound = errors.New("things3: task not found") // ErrAreaNotFound is returned when an area with the specified UUID does not exist. ErrAreaNotFound = errors.New("things3: area not found") // ErrTagNotFound is returned when a tag with the specified title does not exist. ErrTagNotFound = errors.New("things3: tag not found") // ErrInvalidParameter is returned when an invalid parameter value is provided. ErrInvalidParameter = errors.New("things3: invalid parameter") )
Query Errors
var ( // ErrAuthTokenNotFound is returned when the URL scheme auth token cannot be read. ErrAuthTokenNotFound = errors.New("things3: auth token not found") // ErrEmptyToken is returned when an empty token is provided to WithToken. ErrEmptyToken = errors.New("things3: empty token provided to WithToken") // ErrIDRequired is returned when id is missing for an update operation. ErrIDRequired = errors.New("things3: id required for update operation") // ErrTitleTooLong is returned when title exceeds 4,000 character limit. ErrTitleTooLong = errors.New("things3: title exceeds 4,000 character limit") // ErrNotesTooLong is returned when notes exceed 10,000 character limit. ErrNotesTooLong = errors.New("things3: notes exceed 10,000 character limit") // ErrTooManyChecklistItems is returned when checklist exceeds 100 item limit. ErrTooManyChecklistItems = errors.New("things3: checklist exceeds 100 item limit") // ErrNoJSONItems is returned when building a JSON URL with no items. ErrNoJSONItems = errors.New("things3: no items provided for JSON operation") // ErrInvalidReminderTime is returned when reminder hour or minute is out of range. ErrInvalidReminderTime = errors.New("things3: invalid reminder time (hour must be 0-23, minute must be 0-59)") )
URL Scheme Errors
Functions ¶
func ApplyWhen ¶ added in v0.4.0
func ApplyWhen[T WhenScheduler[T]](b T, when string) T
ApplyWhen parses a when string and applies scheduling to a builder. Supports:
- "today": schedules for today
- "tomorrow": schedules for tomorrow
- "evening": schedules for this evening
- "anytime": removes specific scheduling (anytime)
- "someday": schedules for someday (indefinite future)
- "yyyy-mm-dd": schedules for specific date
Returns the builder unchanged if the format is not recognized.
Example:
todo := scheme.Todo().Title("Task")
todo = things3.ApplyWhen(todo, "today")
todo = things3.ApplyWhen(todo, "2024-12-25")
func DaysAgo ¶ added in v0.4.0
DaysAgo returns the time n days before now. This is useful for filtering tasks by creation date.
Example:
db.Tasks().CreatedAfter(things3.DaysAgo(7)).All(ctx) // tasks from last 7 days
func Headings ¶ added in v0.2.0
Headings creates heading entries for a project's items. Used within batchProjectBuilder.Todos to organize to-dos under headings.
func MonthsAgo ¶ added in v0.4.0
MonthsAgo returns the time n months before now. This is useful for filtering tasks by creation date.
Example:
db.Tasks().CreatedAfter(things3.MonthsAgo(1)).All(ctx) // tasks from last month
func Today ¶ added in v0.4.0
Today returns today's date at midnight (00:00:00) in local timezone. This is useful for scheduling tasks with When().
Example:
scheme.Todo().Title("Morning task").When(things3.Today())
func Tomorrow ¶ added in v0.4.0
Tomorrow returns tomorrow's date at midnight (00:00:00) in local timezone. This is useful for scheduling tasks with When().
Example:
scheme.Todo().Title("Task for tomorrow").When(things3.Tomorrow())
Types ¶
type Area ¶
type Area struct {
UUID string `json:"uuid" yaml:"uuid"`
Type string `json:"type" yaml:"type"` // Always "area"
Title string `json:"title" yaml:"title"`
// Nested items (populated when include_items=true)
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
Items []Task `json:"items,omitempty" yaml:"items,omitempty"`
}
Area represents an area in Things 3.
type AreaQueryBuilder ¶ added in v0.5.0
type AreaQueryBuilder interface {
AreaQueryExecutor
WithUUID(uuid string) AreaQueryBuilder
WithTitle(title string) AreaQueryBuilder
Visible(visible bool) AreaQueryBuilder
InTag(title string) AreaQueryBuilder
HasTag(has bool) AreaQueryBuilder
IncludeItems(include bool) AreaQueryBuilder
}
AreaQueryBuilder provides a fluent interface for building area queries.
type AreaQueryExecutor ¶ added in v0.5.0
type AreaQueryExecutor interface {
All(ctx context.Context) ([]Area, error)
First(ctx context.Context) (*Area, error)
Count(ctx context.Context) (int, error)
}
AreaQueryExecutor executes area queries and returns results.
type AuthBatchCreator ¶ added in v0.5.0
type AuthBatchCreator interface {
AddTodo(configure func(BatchTodoConfigurator)) AuthBatchCreator
AddProject(configure func(BatchProjectConfigurator)) AuthBatchCreator
UpdateTodo(id string, configure func(BatchTodoConfigurator)) AuthBatchCreator
UpdateProject(id string, configure func(BatchProjectConfigurator)) AuthBatchCreator
Reveal(reveal bool) AuthBatchCreator
Build() (string, error)
Execute(ctx context.Context) error
}
AuthBatchCreator builds URLs for batch operations including updates.
type BatchCreator ¶ added in v0.5.0
type BatchCreator interface {
AddTodo(configure func(BatchTodoConfigurator)) BatchCreator
AddProject(configure func(BatchProjectConfigurator)) BatchCreator
Reveal(reveal bool) BatchCreator
Build() (string, error)
Execute(ctx context.Context) error
}
BatchCreator builds URLs for batch create operations.
type BatchProjectConfigurator ¶ added in v0.5.0
type BatchProjectConfigurator interface {
Title(title string) BatchProjectConfigurator
Notes(notes string) BatchProjectConfigurator
PrependNotes(notes string) BatchProjectConfigurator
AppendNotes(notes string) BatchProjectConfigurator
When(t time.Time) BatchProjectConfigurator
WhenEvening() BatchProjectConfigurator
WhenAnytime() BatchProjectConfigurator
WhenSomeday() BatchProjectConfigurator
Deadline(t time.Time) BatchProjectConfigurator
Tags(tags ...string) BatchProjectConfigurator
AddTags(tags ...string) BatchProjectConfigurator
Area(name string) BatchProjectConfigurator
AreaID(id string) BatchProjectConfigurator
Todos(configs ...func(BatchTodoConfigurator)) BatchProjectConfigurator
Completed(completed bool) BatchProjectConfigurator
Canceled(canceled bool) BatchProjectConfigurator
CreationDate(date time.Time) BatchProjectConfigurator
CompletionDate(date time.Time) BatchProjectConfigurator
}
BatchProjectConfigurator configures a project entry for batch operations.
type BatchTodoConfigurator ¶ added in v0.5.0
type BatchTodoConfigurator interface {
Title(title string) BatchTodoConfigurator
Notes(notes string) BatchTodoConfigurator
PrependNotes(notes string) BatchTodoConfigurator
AppendNotes(notes string) BatchTodoConfigurator
When(t time.Time) BatchTodoConfigurator
WhenEvening() BatchTodoConfigurator
WhenAnytime() BatchTodoConfigurator
WhenSomeday() BatchTodoConfigurator
Deadline(t time.Time) BatchTodoConfigurator
Tags(tags ...string) BatchTodoConfigurator
AddTags(tags ...string) BatchTodoConfigurator
ChecklistItems(items ...string) BatchTodoConfigurator
List(name string) BatchTodoConfigurator
ListID(id string) BatchTodoConfigurator
Heading(name string) BatchTodoConfigurator
Completed(completed bool) BatchTodoConfigurator
Canceled(canceled bool) BatchTodoConfigurator
CreationDate(date time.Time) BatchTodoConfigurator
CompletionDate(date time.Time) BatchTodoConfigurator
}
BatchTodoConfigurator configures a to-do entry for batch operations.
type ChecklistItem ¶
type ChecklistItem struct {
UUID string `json:"uuid" yaml:"uuid"`
Type string `json:"type" yaml:"type"` // Always "checklist-item"
Title string `json:"title" yaml:"title"`
Status string `json:"status" yaml:"status"` // "incomplete", "completed", or "canceled"
// StopDate: completion date.
// Database: "2024-01-15" (date only, format "YYYY-MM-DD")
// Parsed: time.Time with zero time component
StopDate *time.Time `json:"stop_date,omitempty" yaml:"stop_date,omitempty"`
// Created: item creation timestamp.
// Database: "2024-01-15 10:30:45" (datetime, format "YYYY-MM-DD HH:MM:SS")
// Parsed: time.Time with full date and time
Created time.Time `json:"created" yaml:"created"`
// Modified: last modification timestamp.
// Database: "2024-01-15 10:30:45" (datetime, format "YYYY-MM-DD HH:MM:SS")
// Parsed: time.Time with full date and time
Modified time.Time `json:"modified" yaml:"modified"`
}
ChecklistItem represents a checklist item within a to-do.
func (*ChecklistItem) IsCanceled ¶
func (c *ChecklistItem) IsCanceled() bool
IsCanceled returns true if the checklist item is canceled.
func (*ChecklistItem) IsCompleted ¶
func (c *ChecklistItem) IsCompleted() bool
IsCompleted returns true if the checklist item is completed.
func (*ChecklistItem) IsIncomplete ¶
func (c *ChecklistItem) IsIncomplete() bool
IsIncomplete returns true if the checklist item is incomplete.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides unified access to Things 3 database and URL scheme operations. It combines read-only database access with URL scheme write operations, handling authentication token management automatically.
Create a client using NewClient:
client, err := things3.NewClient()
if err != nil {
log.Fatal(err)
}
defer client.Close()
Query operations read from the Things 3 database:
tasks, _ := client.Inbox(ctx) tasks, _ := client.Tasks().Status().Incomplete().All(ctx)
Add operations create new items via URL scheme:
client.AddTodo().Title("Buy milk").Execute(ctx)
Update operations automatically manage authentication tokens:
client.UpdateTodo(uuid).Completed(true).Execute(ctx)
Show operations display items in the Things app:
client.Show(ctx, uuid)
func NewClient ¶ added in v0.5.0
func NewClient(opts ...ClientOption) (*Client, error)
NewClient creates a new unified Things 3 client. It opens a database connection and initializes the URL scheme handler.
Returns an error if the database cannot be found or opened.
Example:
client, err := things3.NewClient()
if err != nil {
log.Fatal(err)
}
defer client.Close()
// With options
client, err := things3.NewClient(
things3.WithDatabasePath("/custom/path"),
things3.WithPrintSQL(true),
)
func (*Client) AddProject ¶ added in v0.5.0
func (c *Client) AddProject() ProjectAdder
AddProject returns a ProjectAdder for creating a new project.
Example:
client.AddProject().
Title("Home Renovation").
Notes("Kitchen and bathroom").
Execute(ctx)
func (*Client) AddTodo ¶ added in v0.5.0
AddTodo returns a TodoAdder for creating a new to-do.
Example:
client.AddTodo().
Title("Buy milk").
Notes("From the grocery store").
When(things3.Today()).
Execute(ctx)
func (*Client) Areas ¶
func (c *Client) Areas() AreaQueryBuilder
Areas creates a new AreaQueryBuilder for querying areas.
func (*Client) AuthBatch ¶ added in v0.5.0
func (c *Client) AuthBatch() AuthBatchCreator
AuthBatch returns an AuthBatchCreator for batch operations including updates. The authentication token is fetched automatically on first use.
Example:
client.AuthBatch().
AddTodo(func(b BatchTodoConfigurator) {
b.Title("New task")
}).
UpdateTodo("uuid", func(b BatchTodoConfigurator) {
b.Completed(true)
}).
Execute(ctx)
func (*Client) Batch ¶ added in v0.5.0
func (c *Client) Batch() BatchCreator
Batch returns a BatchCreator for batch create operations.
Example:
client.Batch().
AddTodo(func(b BatchTodoConfigurator) {
b.Title("Task 1")
}).
AddTodo(func(b BatchTodoConfigurator) {
b.Title("Task 2")
}).
Execute(ctx)
func (*Client) ChecklistItems ¶
ChecklistItems returns the checklist items for a to-do.
func (*Client) CreatedWithin ¶ added in v0.5.0
CreatedWithin returns tasks created after the specified time.
func (*Client) Get ¶
Get retrieves an object by UUID. Returns a Task, Area, or Tag depending on what is found. Returns nil if not found.
func (*Client) Show ¶
Show opens Things and displays the item with the given UUID. By default, brings Things to foreground since the user wants to view the item. Use WithBackgroundNavigation() option to run in background without stealing focus.
func (*Client) ShowBuilder ¶ added in v0.5.0
func (c *Client) ShowBuilder() ShowNavigator
ShowBuilder returns a ShowNavigator for complex navigation operations.
func (*Client) ShowList ¶ added in v0.5.0
ShowList opens Things and displays the specified list. Use ListID constants like ListInbox, ListToday, etc.
Example:
client.ShowList(ctx, things3.ListToday)
func (*Client) ShowSearch ¶ added in v0.5.0
ShowSearch opens Things and performs a search for the given query. By default, brings Things to foreground since the user wants to view results.
func (*Client) Tags ¶
func (c *Client) Tags() TagQueryBuilder
Tags creates a new TagQueryBuilder for querying tags.
func (*Client) Tasks ¶
func (c *Client) Tasks() TaskQueryBuilder
Tasks creates a new TaskQueryBuilder for querying tasks.
func (*Client) Token ¶
Token returns the cached authentication token, fetching it if needed. Most users should not need this; use UpdateTodo/UpdateProject directly.
func (*Client) UpdateProject ¶ added in v0.5.0
func (c *Client) UpdateProject(id string) ProjectUpdater
UpdateProject returns a ProjectUpdater for modifying an existing project. The authentication token is fetched automatically on first use.
Example:
client.UpdateProject(uuid).
Title("Renamed Project").
Execute(ctx)
func (*Client) UpdateTodo ¶ added in v0.5.0
func (c *Client) UpdateTodo(id string) TodoUpdater
UpdateTodo returns a TodoUpdater for modifying an existing to-do. The authentication token is fetched automatically on first use.
Example:
client.UpdateTodo(uuid).
Completed(true).
Execute(ctx)
type ClientOption ¶ added in v0.5.0
type ClientOption func(*clientOptions)
ClientOption is a functional option for configuring the Client.
func WithBackgroundNavigation ¶ added in v0.5.0
func WithBackgroundNavigation() ClientOption
WithBackgroundNavigation configures the Client to run navigation operations (Show, ShowList, ShowSearch) in the background without stealing focus.
By default, navigation operations bring Things to foreground since the user typically wants to view the content. Use this option for programmatic navigation where focus change is undesired.
Example:
client, err := things3.NewClient(things3.WithBackgroundNavigation()) client.Show(ctx, "uuid") // Things stays in background
func WithDatabasePath ¶
func WithDatabasePath(path string) ClientOption
WithDatabasePath sets a custom path to the Things database. If not set, the database path is discovered automatically.
Example:
client, err := things3.NewClient(things3.WithDatabasePath("/path/to/main.sqlite"))
func WithForegroundExecution ¶ added in v0.5.0
func WithForegroundExecution() ClientOption
WithForegroundExecution configures the Client to bring Things to foreground when executing create/update operations (AddTodo, AddProject, UpdateTodo, etc.).
By default, create/update operations run in background without stealing focus. Use this option when you want Things to become the active window after operations.
Example:
client, err := things3.NewClient(things3.WithForegroundExecution())
client.AddTodo().Title("Buy milk").Execute(ctx) // Things comes to foreground
func WithPreloadToken ¶ added in v0.5.0
func WithPreloadToken() ClientOption
WithPreloadToken fetches the authentication token immediately during NewClient() instead of lazily on first update operation.
Use this option when you know you will need authenticated operations and want to fail fast if the token cannot be retrieved.
Example:
client, err := things3.NewClient(things3.WithPreloadToken())
if err != nil {
// May fail due to token retrieval error
}
func WithPrintSQL ¶
func WithPrintSQL(enabled bool) ClientOption
WithPrintSQL enables SQL query logging to stdout. Useful for debugging and understanding the queries being executed.
Example:
client, err := things3.NewClient(things3.WithPrintSQL(true))
type Command ¶ added in v0.2.0
type Command string
Command represents Things URL scheme commands.
const ( // CommandShow opens and shows an item. CommandShow Command = "show" // CommandAdd creates a new to-do. CommandAdd Command = "add" // CommandAddProject creates a new project. CommandAddProject Command = "add-project" // CommandUpdate updates an existing item (requires auth token). CommandUpdate Command = "update" // CommandUpdateProject updates an existing project (requires auth token). CommandUpdateProject Command = "update-project" // CommandSearch performs a search. CommandSearch Command = "search" // CommandVersion returns Things version information. CommandVersion Command = "version" // CommandJSON enables advanced JSON-based operations. CommandJSON Command = "json" )
type DateFilterBuilder ¶ added in v0.5.0
type DateFilterBuilder interface {
Exists(has bool) TaskQueryBuilder
Future() TaskQueryBuilder
Past() TaskQueryBuilder
On(date time.Time) TaskQueryBuilder
Before(date time.Time) TaskQueryBuilder
OnOrBefore(date time.Time) TaskQueryBuilder
After(date time.Time) TaskQueryBuilder
OnOrAfter(date time.Time) TaskQueryBuilder
}
DateFilterBuilder provides type-safe date filtering.
type JSONItem ¶ added in v0.2.0
type JSONItem struct {
Type JSONItemType `json:"type"`
Operation JSONOperation `json:"operation,omitempty"`
ID string `json:"id,omitempty"`
Attributes map[string]any `json:"attributes,omitempty"`
}
JSONItem represents a single item in a JSON batch operation.
type JSONItemType ¶ added in v0.2.0
type JSONItemType string
JSONItemType represents the type of item in a JSON operation.
const ( // JSONItemTypeTodo represents a to-do item. JSONItemTypeTodo JSONItemType = "to-do" // JSONItemTypeProject represents a project item. JSONItemTypeProject JSONItemType = "project" )
type JSONOperation ¶ added in v0.2.0
type JSONOperation string
JSONOperation represents the operation type for a JSON item.
const ( // JSONOperationCreate creates a new item. JSONOperationCreate JSONOperation = "create" // JSONOperationUpdate updates an existing item. JSONOperationUpdate JSONOperation = "update" )
type ListID ¶ added in v0.2.0
type ListID string
ListID represents built-in Things list identifiers for the show command.
const ( // ListInbox is the Inbox list. ListInbox ListID = "inbox" // ListToday is the Today list. ListToday ListID = "today" // ListAnytime is the Anytime list. ListAnytime ListID = "anytime" // ListUpcoming is the Upcoming list. ListUpcoming ListID = "upcoming" // ListSomeday is the Someday list. ListSomeday ListID = "someday" // ListLogbook is the Logbook list. ListLogbook ListID = "logbook" // ListTomorrow is the Tomorrow list. ListTomorrow ListID = "tomorrow" // ListDeadlines is the Deadlines list. ListDeadlines ListID = "deadlines" // ListRepeating is the Repeating list. ListRepeating ListID = "repeating" // ListAllProjects is the All Projects list. ListAllProjects ListID = "all-projects" // ListLoggedProjects is the Logged Projects list. ListLoggedProjects ListID = "logged-projects" )
type ProjectAdder ¶ added in v0.5.0
type ProjectAdder interface {
URLBuilder
Title(title string) ProjectAdder
Notes(notes string) ProjectAdder
When(t time.Time) ProjectAdder
WhenEvening() ProjectAdder
WhenAnytime() ProjectAdder
WhenSomeday() ProjectAdder
Deadline(t time.Time) ProjectAdder
Reminder(hour, minute int) ProjectAdder
Tags(tags ...string) ProjectAdder
Area(name string) ProjectAdder
AreaID(id string) ProjectAdder
Todos(titles ...string) ProjectAdder
Completed(completed bool) ProjectAdder
Canceled(canceled bool) ProjectAdder
Reveal(reveal bool) ProjectAdder
CreationDate(date time.Time) ProjectAdder
CompletionDate(date time.Time) ProjectAdder
}
ProjectAdder builds URLs for creating new projects.
type ProjectUpdater ¶ added in v0.5.0
type ProjectUpdater interface {
URLBuilder
Title(title string) ProjectUpdater
Notes(notes string) ProjectUpdater
PrependNotes(notes string) ProjectUpdater
AppendNotes(notes string) ProjectUpdater
When(t time.Time) ProjectUpdater
WhenEvening() ProjectUpdater
WhenAnytime() ProjectUpdater
WhenSomeday() ProjectUpdater
Deadline(t time.Time) ProjectUpdater
ClearDeadline() ProjectUpdater
Reminder(hour, minute int) ProjectUpdater
Tags(tags ...string) ProjectUpdater
AddTags(tags ...string) ProjectUpdater
Area(name string) ProjectUpdater
AreaID(id string) ProjectUpdater
Completed(completed bool) ProjectUpdater
Canceled(canceled bool) ProjectUpdater
Reveal(reveal bool) ProjectUpdater
}
ProjectUpdater builds URLs for updating existing projects.
type ShowNavigator ¶ added in v0.5.0
type ShowNavigator interface {
}
ShowNavigator builds URLs for navigating to items or lists.
type StartBucket ¶
type StartBucket int
StartBucket represents the scheduling bucket for a task.
const ( // StartInbox indicates the task is in the Inbox. StartInbox StartBucket = 0 // StartAnytime indicates the task is scheduled for Anytime. StartAnytime StartBucket = 1 // StartSomeday indicates the task is scheduled for Someday. StartSomeday StartBucket = 2 )
func (StartBucket) String ¶
func (s StartBucket) String() string
String returns the string representation of the StartBucket.
type StartFilterBuilder ¶ added in v0.5.0
type StartFilterBuilder interface {
Inbox() TaskQueryBuilder
Anytime() TaskQueryBuilder
Someday() TaskQueryBuilder
}
StartFilterBuilder provides type-safe start bucket filtering.
type Status ¶
type Status int
Status represents the completion status of a task.
func (Status) IsClosed ¶
IsClosed returns true if the status indicates a closed (completed or canceled) task.
func (Status) MarshalJSON ¶ added in v0.5.0
MarshalJSON implements json.Marshaler for Status.
func (Status) MarshalYAML ¶ added in v0.5.0
MarshalYAML implements yaml.Marshaler for Status.
func (*Status) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON implements json.Unmarshaler for Status.
type StatusFilterBuilder ¶ added in v0.5.0
type StatusFilterBuilder interface {
Incomplete() TaskQueryBuilder
Completed() TaskQueryBuilder
Canceled() TaskQueryBuilder
Any() TaskQueryBuilder
}
StatusFilterBuilder provides type-safe status filtering.
type Tag ¶
type Tag struct {
UUID string `json:"uuid" yaml:"uuid"`
Type string `json:"type" yaml:"type"` // Always "tag"
Title string `json:"title" yaml:"title"`
Shortcut string `json:"shortcut,omitempty" yaml:"shortcut,omitempty"`
// Nested items (populated when include_items=true)
Items []any `json:"items,omitempty" yaml:"items,omitempty"` // Can contain Area or Task
}
Tag represents a tag in Things 3.
type TagQueryBuilder ¶ added in v0.5.0
type TagQueryBuilder interface {
TagQueryExecutor
WithUUID(uuid string) TagQueryBuilder
WithTitle(title string) TagQueryBuilder
WithParent(parentUUID string) TagQueryBuilder
IncludeItems(include bool) TagQueryBuilder
}
TagQueryBuilder provides a fluent interface for building tag queries.
type TagQueryExecutor ¶ added in v0.5.0
type TagQueryExecutor interface {
All(ctx context.Context) ([]Tag, error)
First(ctx context.Context) (*Tag, error)
}
TagQueryExecutor executes tag queries and returns results.
type Task ¶
type Task struct {
UUID string `json:"uuid" yaml:"uuid"`
Type TaskType `json:"type" yaml:"type"`
Title string `json:"title" yaml:"title"`
Status Status `json:"status" yaml:"status"`
Notes string `json:"notes,omitempty" yaml:"notes,omitempty"`
Start string `json:"start,omitempty" yaml:"start,omitempty"` // "Inbox", "Anytime", or "Someday"
// Trashed indicates whether the task is in the trash.
Trashed bool `json:"trashed,omitempty" yaml:"trashed,omitempty"`
// Relationships
AreaUUID *string `json:"area_uuid,omitempty" yaml:"area_uuid,omitempty"`
AreaTitle *string `json:"area_title,omitempty" yaml:"area_title,omitempty"`
ProjectUUID *string `json:"project_uuid,omitempty" yaml:"project_uuid,omitempty"`
ProjectTitle *string `json:"project_title,omitempty" yaml:"project_title,omitempty"`
HeadingUUID *string `json:"heading_uuid,omitempty" yaml:"heading_uuid,omitempty"`
HeadingTitle *string `json:"heading_title,omitempty" yaml:"heading_title,omitempty"`
// Dates
// All date/time fields are converted from SQLite string formats to time.Time.
//
// StartDate: scheduled start date.
// Database: "2024-01-15" (date only, format "YYYY-MM-DD")
// Parsed: time.Time with zero time component
StartDate *time.Time `json:"start_date,omitempty" yaml:"start_date,omitempty"`
// Deadline: task deadline date.
// Database: "2024-01-15" (date only, format "YYYY-MM-DD")
// Parsed: time.Time with zero time component
Deadline *time.Time `json:"deadline,omitempty" yaml:"deadline,omitempty"`
// ReminderTime: time-only reminder (date component is zero value).
// Database: "14:30" (time only, format "HH:MM")
// Parsed: time.Time with zero date (0000-01-01), only Hour/Minute meaningful
ReminderTime *time.Time `json:"reminder_time,omitempty" yaml:"reminder_time,omitempty"`
// StopDate: completion or cancellation timestamp.
// Database: "2024-01-15 10:30:45" (datetime, format "YYYY-MM-DD HH:MM:SS")
// Parsed: time.Time with full date and time
StopDate *time.Time `json:"stop_date,omitempty" yaml:"stop_date,omitempty"`
// Created: task creation timestamp.
// Database: "2024-01-15 10:30:45" (datetime, format "YYYY-MM-DD HH:MM:SS")
// Parsed: time.Time with full date and time
Created time.Time `json:"created" yaml:"created"`
// Modified: last modification timestamp.
// Database: "2024-01-15 10:30:45" (datetime, format "YYYY-MM-DD HH:MM:SS")
// Parsed: time.Time with full date and time
Modified time.Time `json:"modified" yaml:"modified"`
// Index values for ordering
Index int `json:"index" yaml:"index"`
TodayIndex int `json:"today_index" yaml:"today_index"`
// Nested items (populated when include_items=true)
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
Checklist []ChecklistItem `json:"checklist,omitempty" yaml:"checklist,omitempty"`
Items []Task `json:"items,omitempty" yaml:"items,omitempty"` // For projects and headings
}
Task represents a task in Things 3, which can be a to-do, project, or heading.
func (*Task) HasChecklist ¶
HasChecklist returns true if the task has a checklist.
func (*Task) IsCanceled ¶
IsCanceled returns true if the task status is canceled.
func (*Task) IsCompleted ¶
IsCompleted returns true if the task status is completed.
func (*Task) IsIncomplete ¶
IsIncomplete returns true if the task status is incomplete.
type TaskQueryBuilder ¶ added in v0.5.0
type TaskQueryBuilder interface {
TaskQueryExecutor
TaskRelationFilter
TaskStateFilter
TaskTimeFilter
WithUUID(uuid string) TaskQueryBuilder
WithUUIDPrefix(prefix string) TaskQueryBuilder
WithDeadlineSuppressed(suppressed bool) TaskQueryBuilder
Search(query string) TaskQueryBuilder
OrderByTodayIndex() TaskQueryBuilder
IncludeItems(include bool) TaskQueryBuilder
}
TaskQueryBuilder provides a fluent interface for building task queries. Composed of: TaskQueryExecutor + TaskRelationFilter + TaskStateFilter + TaskTimeFilter
type TaskQueryExecutor ¶ added in v0.5.0
type TaskQueryExecutor interface {
All(ctx context.Context) ([]Task, error)
First(ctx context.Context) (*Task, error)
Count(ctx context.Context) (int, error)
}
TaskQueryExecutor executes task queries and returns results.
type TaskRelationFilter ¶ added in v0.5.0
type TaskRelationFilter interface {
InArea(uuid string) TaskQueryBuilder
HasArea(has bool) TaskQueryBuilder
InProject(uuid string) TaskQueryBuilder
HasProject(has bool) TaskQueryBuilder
InHeading(uuid string) TaskQueryBuilder
HasHeading(has bool) TaskQueryBuilder
InTag(title string) TaskQueryBuilder
HasTag(has bool) TaskQueryBuilder
}
TaskRelationFilter provides relation-based filtering for tasks.
type TaskStateFilter ¶ added in v0.5.0
type TaskStateFilter interface {
Type() TypeFilterBuilder
Status() StatusFilterBuilder
Start() StartFilterBuilder
Trashed(trashed bool) TaskQueryBuilder
ContextTrashed(trashed bool) TaskQueryBuilder
}
TaskStateFilter provides state and type filtering for tasks.
type TaskTimeFilter ¶ added in v0.5.0
type TaskTimeFilter interface {
CreatedAfter(t time.Time) TaskQueryBuilder
StartDate() DateFilterBuilder
StopDate() DateFilterBuilder
Deadline() DateFilterBuilder
}
TaskTimeFilter provides time-based filtering for tasks.
type TaskType ¶
type TaskType int
TaskType represents the kind of task in Things 3. Tasks can be to-dos, projects, or headings within projects.
func (TaskType) MarshalJSON ¶ added in v0.5.0
MarshalJSON implements json.Marshaler for TaskType.
func (TaskType) MarshalYAML ¶ added in v0.5.0
MarshalYAML implements yaml.Marshaler for TaskType.
func (*TaskType) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON implements json.Unmarshaler for TaskType.
type TodoAdder ¶ added in v0.5.0
type TodoAdder interface {
URLBuilder
Title(title string) TodoAdder
Titles(titles ...string) TodoAdder
Notes(notes string) TodoAdder
When(t time.Time) TodoAdder
WhenEvening() TodoAdder
WhenAnytime() TodoAdder
WhenSomeday() TodoAdder
Deadline(t time.Time) TodoAdder
Reminder(hour, minute int) TodoAdder
Tags(tags ...string) TodoAdder
ChecklistItems(items ...string) TodoAdder
List(name string) TodoAdder
ListID(id string) TodoAdder
Heading(name string) TodoAdder
HeadingID(id string) TodoAdder
Completed(completed bool) TodoAdder
Canceled(canceled bool) TodoAdder
ShowQuickEntry(show bool) TodoAdder
Reveal(reveal bool) TodoAdder
CreationDate(date time.Time) TodoAdder
CompletionDate(date time.Time) TodoAdder
}
TodoAdder builds URLs for creating new to-dos.
type TodoUpdater ¶ added in v0.5.0
type TodoUpdater interface {
URLBuilder
Title(title string) TodoUpdater
Notes(notes string) TodoUpdater
PrependNotes(notes string) TodoUpdater
AppendNotes(notes string) TodoUpdater
When(t time.Time) TodoUpdater
WhenEvening() TodoUpdater
WhenAnytime() TodoUpdater
WhenSomeday() TodoUpdater
Deadline(t time.Time) TodoUpdater
ClearDeadline() TodoUpdater
Reminder(hour, minute int) TodoUpdater
Tags(tags ...string) TodoUpdater
AddTags(tags ...string) TodoUpdater
ChecklistItems(items ...string) TodoUpdater
PrependChecklistItems(items ...string) TodoUpdater
AppendChecklistItems(items ...string) TodoUpdater
List(name string) TodoUpdater
ListID(id string) TodoUpdater
Heading(name string) TodoUpdater
HeadingID(id string) TodoUpdater
Completed(completed bool) TodoUpdater
Canceled(canceled bool) TodoUpdater
Duplicate(duplicate bool) TodoUpdater
Reveal(reveal bool) TodoUpdater
CreationDate(date time.Time) TodoUpdater
CompletionDate(date time.Time) TodoUpdater
}
TodoUpdater builds URLs for updating existing to-dos.
type TypeFilterBuilder ¶ added in v0.5.0
type TypeFilterBuilder interface {
Todo() TaskQueryBuilder
Project() TaskQueryBuilder
Heading() TaskQueryBuilder
}
TypeFilterBuilder provides type-safe task type filtering.
type URLBuilder ¶ added in v0.5.0
URLBuilder builds and executes Things URL schemes.
type WhenScheduler ¶ added in v0.4.0
type WhenScheduler[T any] interface { When(t time.Time) T WhenEvening() T WhenAnytime() T WhenSomeday() T }
WhenScheduler is implemented by builders that support scheduling. All builder types (TodoBuilder, ProjectBuilder, UpdateTodoBuilder, UpdateProjectBuilder, JSONTodoBuilder, JSONProjectBuilder) satisfy this interface.
Source Files
¶
- client.go
- client_options.go
- constants.go
- convenience.go
- database.go
- date.go
- db.go
- db_options.go
- doc.go
- errors.go
- filter.go
- interfaces.go
- models.go
- query.go
- query_area.go
- query_filter.go
- query_tag.go
- scheme.go
- scheme_attrs.go
- scheme_builder.go
- scheme_constants.go
- scheme_json.go
- scheme_options.go
- scheme_show.go
- scheme_update.go
- sql.go
- time_helpers.go
- types.go
- utils.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package thingstest provides test utilities for projects that depend on the things3 library.
|
Package thingstest provides test utilities for projects that depend on the things3 library. |