drafts

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Separator = '|'

Variables

View Source
var (
	ErrDraftNotFound     = errors.New("draft not found")
	ErrActionNotFound    = errors.New("action not found")
	ErrWorkspaceNotFound = errors.New("workspace not found")
)

Functions

func ActionExists

func ActionExists(name string) (bool, error)

ActionExists reports whether a Drafts action exists by name.

func Active

func Active() (string, error)

func Append

func Append(uuid, text string, opt ModifyOptions) error

func Archive

func Archive(uuid string) error

func Configure

func Configure(app AppInfo, timeout time.Duration)

func Count

func Count(query string, filter Filter, opt QueryOptions, workspace string) (int, error)

func Create

func Create(text string, opt CreateOptions) (string, error)

func CurrentWorkspace

func CurrentWorkspace() (string, error)

func DraftExists

func DraftExists(uuid string) (bool, error)

DraftExists reports whether a Drafts draft exists for the given UUID.

func InspectDictionary

func InspectDictionary(data []byte) (map[string]bool, []string, error)

InspectDictionary uses Apple event codes, including builds with duplicate names.

func IsRunning

func IsRunning() (bool, error)

func Move

func Move(uuid, folder string) error

func OpenWorkspace

func OpenWorkspace(name string) error

func PreflightMutation

func PreflightMutation(action, uuid string, flagType *int) error

PreflightMutation performs only read operations before reserving an idempotency key.

func Prepend

func Prepend(uuid, text string, opt ModifyOptions) error

func RemoveTags

func RemoveTags(uuid string, tags ...string) error

func RenameWorkspace

func RenameWorkspace(name, newName string) error

RenameWorkspace changes a dictionary-supported workspace name without inventing workspace creation or configuration APIs that the dictionary does not expose.

func Replace

func Replace(uuid, text string) error

func ReplaceIfUnchanged

func ReplaceIfUnchanged(uuid, text, original string) error

func RunActionOnDraft

func RunActionOnDraft(action, uuid string) error

RunActionOnDraft runs an action on an existing draft.

func Select

func Select(uuid string) error

func SetFlagType

func SetFlagType(uuid string, flagType int) error

func SetFlagged

func SetFlagged(uuid string, flagged bool) error

func Tag

func Tag(uuid string, tags ...string) error

func Trash

func Trash(uuid string) error

func ValidateDraft

func ValidateDraft(d Draft) error

ValidateDraft verifies untrusted structured data without accessing an application.

func ValidateName

func ValidateName(name string) error

func ValidateUUID

func ValidateUUID(uuid string) error

func WorkspaceExists

func WorkspaceExists(name string) (bool, error)

WorkspaceExists reports whether a Drafts workspace exists by name.

func Workspaces

func Workspaces() ([]string, error)

Types

type ActionRunResult

type ActionRunResult struct {
	UUID         string `json:"uuid"`
	CreatedDraft bool   `json:"createdDraft"`
	Status       string `json:"status"`
}

func RunAction

func RunAction(action, text string) (ActionRunResult, error)

RunAction creates a persistent draft. Action execution is submitted, not guaranteed completed.

type AppInfo

type AppInfo struct {
	Path         string          `json:"path"`
	BundleID     string          `json:"bundle_id"`
	Version      string          `json:"version"`
	Build        string          `json:"build"`
	Channel      string          `json:"channel"`
	Capabilities map[string]bool `json:"capabilities"`
	Warnings     []string        `json:"warnings,omitempty"`
}

AppInfo describes the installed application, never its user library.

func DiscoverApps

func DiscoverApps() ([]AppInfo, error)

func InspectApp

func InspectApp(path string) (AppInfo, error)

InspectApp reads only application metadata and the scripting dictionary.

func SelectApp

func SelectApp(apps []AppInfo, selector, channel string) (AppInfo, error)

type CreateOptions

type CreateOptions struct {
	Tags     []string
	Folder   Folder
	Flagged  bool
	Action   string
	FlagType *int
}

type Draft

type Draft struct {
	AccessedAt        string   `json:"accessedAt,omitempty"`
	FlagType          *int     `json:"flagType,omitempty"`
	UUID              string   `json:"uuid"`
	Content           string   `json:"content"`
	Title             string   `json:"title"`
	Tags              []string `json:"tags"`
	IsFlagged         bool     `json:"isFlagged"`
	IsArchived        bool     `json:"isArchived"`
	IsTrashed         bool     `json:"isTrashed"`
	Folder            string   `json:"folder"`
	CreatedAt         string   `json:"createdAt"`
	ModifiedAt        string   `json:"modifiedAt"`
	CreatedLatitude   float64  `json:"createdLatitude"`
	CreatedLongitude  float64  `json:"createdLongitude"`
	ModifiedLatitude  float64  `json:"modifiedLatitude"`
	ModifiedLongitude float64  `json:"modifiedLongitude"`
	Permalink         string   `json:"permalink"`
}

func Get

func Get(uuid string) (Draft, error)

func Query

func Query(query string, filter Filter, opt QueryOptions) ([]Draft, error)

func QueryWorkspace

func QueryWorkspace(workspace, query string, filter Filter, opt QueryOptions) ([]Draft, error)

type Error

type Error struct {
	Code            string   `json:"code"`
	Message         string   `json:"message"`
	Hint            string   `json:"hint,omitempty"`
	UUID            string   `json:"uuid,omitempty"`
	Completed       []string `json:"completed,omitempty"`
	RetrySafe       bool     `json:"retry_safe"`
	AppleScriptCode int      `json:"applescript_code,omitempty"`
	Cause           error    `json:"-"`
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Filter

type Filter int
const (
	FilterInbox Filter = iota
	FilterFlagged
	FilterArchive
	FilterTrash
	FilterAll
)

func (Filter) String

func (f Filter) String() string

type Folder

type Folder int
const (
	FolderInbox Folder = iota
	FolderArchive
)

func (Folder) String

func (f Folder) String() string

type ModifyOptions

type ModifyOptions struct {
	Separator *string
	Tags      []string
	Action    string
}

type NamedResource

type NamedResource struct {
	ID        string `json:"id,omitempty"`
	Name      string `json:"name"`
	Permalink string `json:"permalink,omitempty"`
}

func Actions

func Actions() ([]NamedResource, error)

func Resources

func Resources(kind string) ([]NamedResource, error)

func Tags

func Tags() ([]NamedResource, error)

type QueryOptions

type QueryOptions struct {
	Tags             []string
	OmitTags         []string
	Sort             Sort
	SortDescending   bool
	SortFlaggedToTop bool
	Limit            int
	Full             bool
	FlagType         *int
	CreatedAfter     string
	CreatedBefore    string
	ModifiedAfter    string
	ModifiedBefore   string
}

type Sort

type Sort int
const (
	SortCreated Sort = iota
	SortModified
	SortAccessed
)

func (Sort) String

func (s Sort) String() string

Jump to

Keyboard shortcuts

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