app

package
v0.0.0-...-d277e4d Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package app exposes shared services for manipulating bujo entries and collections.

Index

Constants

This section is empty.

Variables

View Source
var ErrImmutable = errors.New("app: entry is immutable")

ErrImmutable indicates operations on an immutable entry are not allowed.

View Source
var ErrInvalidCollection = errors.New("app: invalid collection")

ErrInvalidCollection indicates a collection path or segment was invalid.

Functions

This section is empty.

Types

type MigrationCandidate

type MigrationCandidate struct {
	Entry       *entry.Entry
	Parent      *entry.Entry
	LastTouched time.Time
}

MigrationCandidate represents an open task that needs attention during a migration session.

type ReportItem

type ReportItem struct {
	Entry       *entry.Entry
	Completed   bool
	CompletedAt time.Time
}

ReportItem captures a completed entry and the timestamp it was completed.

type ReportResult

type ReportResult struct {
	Since    time.Time
	Until    time.Time
	Sections []ReportSection
	Total    int
}

ReportResult encapsulates a completed-entries report for a time window.

type ReportSection

type ReportSection struct {
	Collection string
	Entries    []ReportItem
}

ReportSection groups completed entries by collection.

type Service

type Service struct {
	Persistence store.Persistence
}

Service provides high-level operations for entries and collections. It wraps persistence and entry transformations so UIs and CLIs can share logic.

func (*Service) Add

func (s *Service) Add(_ context.Context, collection string, b glyph.Bullet, msg string, sig glyph.Signifier) (*entry.Entry, error)

Add creates and stores a new entry.

func (*Service) AddDependsOn

func (s *Service) AddDependsOn(ctx context.Context, id string, dependsOn []string) (*entry.Entry, error)

AddDependsOn merges dependency IDs into the entry.

func (*Service) AddLabels

func (s *Service) AddLabels(ctx context.Context, id string, labels []string) (*entry.Entry, error)

AddLabels merges labels into the entry.

func (*Service) ClearDependsOn

func (s *Service) ClearDependsOn(ctx context.Context, id string) (*entry.Entry, error)

ClearDependsOn removes all dependencies from the entry.

func (*Service) ClearLabels

func (s *Service) ClearLabels(ctx context.Context, id string) (*entry.Entry, error)

ClearLabels removes all labels from the entry.

func (*Service) Collections

func (s *Service) Collections(ctx context.Context) ([]string, error)

Collections returns sorted collection names.

func (*Service) CollectionsMeta

func (s *Service) CollectionsMeta(ctx context.Context, prefix string) ([]collection.Meta, error)

CollectionsMeta returns collection metadata filtered by prefix.

func (*Service) Complete

func (s *Service) Complete(ctx context.Context, id string) (*entry.Entry, error)

Complete marks an entry completed.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete removes an entry permanently.

func (*Service) DeleteCollection

func (s *Service) DeleteCollection(ctx context.Context, collectionName string) error

DeleteCollection removes a collection and its descendants.

func (*Service) Edit

func (s *Service) Edit(ctx context.Context, id string, newMsg string) (*entry.Entry, error)

Edit updates the message for the entry with the given id.

func (*Service) EnsureCollection

func (s *Service) EnsureCollection(ctx context.Context, collection string) error

EnsureCollection ensures the named collection exists even if empty.

func (*Service) EnsureCollectionOfType

func (s *Service) EnsureCollectionOfType(ctx context.Context, collectionName string, typ collection.Type) error

EnsureCollectionOfType ensures the collection exists and records its type.

func (*Service) EnsureCollections

func (s *Service) EnsureCollections(ctx context.Context, collections []string) error

EnsureCollections ensures each collection in the slice exists.

func (*Service) Entries

func (s *Service) Entries(ctx context.Context, collection string) ([]*entry.Entry, error)

Entries lists entries for a collection.

func (*Service) Lock

func (s *Service) Lock(ctx context.Context, id string) (*entry.Entry, error)

Lock marks an entry immutable.

func (*Service) MigrationCandidates

func (s *Service) MigrationCandidates(ctx context.Context, since, until time.Time) ([]MigrationCandidate, error)

MigrationCandidates returns open, completable entries that require review in a migration session. When the since window is zero, all open tasks/events outside the Future tree (and not scheduled on future daily collections) are returned alongside top-level Future entries. When a non-zero window is provided, candidates must have been touched within the window, with top-level Future entries always included. LastTouched reflects the most recent history record (or creation time).

func (*Service) Move

func (s *Service) Move(ctx context.Context, id string, target string) (*entry.Entry, error)

Move clones an entry into the target collection and marks the original as moved.

func (*Service) RemoveDependsOn

func (s *Service) RemoveDependsOn(ctx context.Context, id string, dependsOn []string) (*entry.Entry, error)

RemoveDependsOn removes dependency IDs from the entry.

func (*Service) RemoveLabels

func (s *Service) RemoveLabels(ctx context.Context, id string, labels []string) (*entry.Entry, error)

RemoveLabels removes labels from the entry.

func (*Service) Report

func (s *Service) Report(ctx context.Context, since, until time.Time) (ReportResult, error)

Report returns completed entries grouped by collection between the provided bounds.

func (*Service) SetBullet

func (s *Service) SetBullet(ctx context.Context, id string, b glyph.Bullet) (*entry.Entry, error)

SetBullet sets the bullet type for the entry id.

func (*Service) SetCollectionType

func (s *Service) SetCollectionType(ctx context.Context, collectionName string, typ collection.Type) error

SetCollectionType updates metadata for an existing collection.

func (*Service) SetDependsOn

func (s *Service) SetDependsOn(ctx context.Context, id string, dependsOn []string) (*entry.Entry, error)

SetDependsOn replaces dependency IDs with the provided canonicalized set.

func (*Service) SetLabels

func (s *Service) SetLabels(ctx context.Context, id string, labels []string) (*entry.Entry, error)

SetLabels replaces the entry labels with the provided canonicalized set.

func (*Service) SetParent

func (s *Service) SetParent(ctx context.Context, id, parentID string) (*entry.Entry, error)

SetParent reassigns the parent relationship for an entry within a collection.

func (*Service) SetSignifier

func (s *Service) SetSignifier(ctx context.Context, id string, sig glyph.Signifier) (*entry.Entry, error)

SetSignifier assigns the provided signifier to the entry id.

func (*Service) Strike

func (s *Service) Strike(ctx context.Context, id string) (*entry.Entry, error)

Strike marks an entry irrelevant (strike-through semantics).

func (*Service) ToggleSignifier

func (s *Service) ToggleSignifier(ctx context.Context, id string, sig glyph.Signifier) (*entry.Entry, error)

ToggleSignifier toggles a given signifier on/off for the entry id. If the same signifier is set, it clears it; otherwise it sets it.

func (*Service) Unlock

func (s *Service) Unlock(ctx context.Context, id string) (*entry.Entry, error)

Unlock clears the immutable flag.

func (*Service) Watch

func (s *Service) Watch(ctx context.Context) (<-chan store.Event, error)

Watch subscribes to persistence change events.

Jump to

Keyboard shortcuts

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