workflowy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAPIKey

func WithAPIKey(apiKey string) client.Option

WithAPIKey sets up Bearer token authentication

func WithAPIKeyFromFile

func WithAPIKeyFromFile(filename string) client.Option

WithAPIKeyFromFile reads API key from file and sets up Bearer token authentication

Types

type BackupNode

type BackupNode struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"nm"`
	Note       *string                `json:"no,omitempty"`
	Children   []BackupNode           `json:"ch,omitempty"`
	CreatedAt  int64                  `json:"ct,omitempty"`
	ModifiedAt int64                  `json:"lm,omitempty"`
	Completed  *int64                 `json:"cp,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

BackupNode represents a node from a Workflowy backup file Backup files use different field names than the API (nm, ch, ct, lm)

type ChildrenCountRankable

type ChildrenCountRankable struct {
	Node *NodeWithTimestamps
}

ChildrenCountRankable implements ranking by children count

func RankByChildrenCount

func RankByChildrenCount(nodes []*NodeWithTimestamps, topN int) []ChildrenCountRankable

RankByChildrenCount ranks nodes by their immediate children count

func (*ChildrenCountRankable) GetRankingValue

func (r *ChildrenCountRankable) GetRankingValue() int

func (*ChildrenCountRankable) GetValue

func (r *ChildrenCountRankable) GetValue() fmt.Stringer

func (ChildrenCountRankable) String

func (r ChildrenCountRankable) String() string

type CreateNodeRequest

type CreateNodeRequest struct {
	ParentID   string  `json:"parent_id"`
	Name       string  `json:"name"`
	Note       *string `json:"note,omitempty"`
	LayoutMode *string `json:"layoutMode,omitempty"`
	Position   *string `json:"position,omitempty"`
}

CreateNodeRequest represents the request payload for nodes-create API

type CreateNodeResponse

type CreateNodeResponse struct {
	ItemID string `json:"item_id"`
}

CreateNodeResponse represents the response from nodes-create API

type Descendants

type Descendants = *counter.DescendantTreeCount[**ItemNode]

Descendants is a type alias for descendant tree count

func CountDescendants

func CountDescendants(item *Item, threshold float64) Descendants

CountDescendants counts descendants in a tree and returns filtered, sorted results

type ExportNode

type ExportNode struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Note        *string                `json:"note"`
	ParentID    *string                `json:"parent_id"`
	Priority    int                    `json:"priority"`
	Completed   bool                   `json:"completed"`
	Data        map[string]interface{} `json:"data"`
	CreatedAt   int64                  `json:"createdAt"`
	ModifiedAt  int64                  `json:"modifiedAt"`
	CompletedAt *int64                 `json:"completedAt"`
}

ExportNode represents a node from the export API with parent_id for tree reconstruction

type ExportNodesResponse

type ExportNodesResponse struct {
	Nodes []ExportNode `json:"nodes"`
}

ExportNodesResponse represents the response from GET /nodes-export

type GetItemResponse

type GetItemResponse struct {
	Node Item `json:"node"`
}

GetItemResponse represents the response from GET /nodes/:id

type Item

type Item struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Note        *string                `json:"note"`
	Priority    int                    `json:"priority"`
	Data        map[string]interface{} `json:"data"`
	CreatedAt   int64                  `json:"createdAt"`
	ModifiedAt  int64                  `json:"modifiedAt"`
	CompletedAt *int64                 `json:"completedAt"`
	Children    []*Item                `json:"children,omitempty"`
}

Item represents a Workflowy item with all its properties

func BackupNodeToItem

func BackupNodeToItem(node BackupNode) *Item

BackupNodeToItem converts a BackupNode to an Item recursively

func BuildTreeFromExport

func BuildTreeFromExport(nodes []ExportNode) *Item

BuildTreeFromExport reconstructs a tree structure from flat export nodes Returns a root Item containing all top-level nodes as children

func ExportNodeToItem

func ExportNodeToItem(node ExportNode) *Item

ExportNodeToItem converts an ExportNode to an Item

func ReadBackupFile

func ReadBackupFile(filename string) ([]*Item, error)

ReadBackupFile reads and parses a Workflowy backup file

func ReadLatestBackup

func ReadLatestBackup() ([]*Item, error)

ReadLatestBackup reads the most recent backup file from Dropbox folder

type ItemNode

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

ItemNode wraps Item to implement counter.TreeProvider interface

func NewItemNode

func NewItemNode(item *Item) *ItemNode

NewItemNode creates an ItemNode from an Item recursively

func (*ItemNode) Children

func (n *ItemNode) Children() iter.Seq[counter.TreeProvider[*ItemNode]]

Children implements counter.TreeProvider

func (*ItemNode) ExternalURL

func (n *ItemNode) ExternalURL() string

ExternalURL returns the external Workflowy URL for this item

func (*ItemNode) InternalURL

func (n *ItemNode) InternalURL() string

InternalURL returns the internal Workflowy URL for this item

func (*ItemNode) MarshalJSON

func (n *ItemNode) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*ItemNode) Name

func (n *ItemNode) Name() string

Name returns the item's name

func (*ItemNode) Node

func (n *ItemNode) Node() *ItemNode

Node implements counter.TreeProvider

func (*ItemNode) String

func (n *ItemNode) String() string

String implements fmt.Stringer

type ListChildrenResponse

type ListChildrenResponse struct {
	Items []*Item `json:"nodes"` // v1 API uses "nodes" field
}

ListChildrenResponse represents the response from list nodes API

type NodeWithTimestamps

type NodeWithTimestamps struct {
	Count      Descendants
	CreatedAt  int64
	ModifiedAt int64
}

NodeWithTimestamps combines a descendant count node with timestamp information

func CollectNodesWithTimestamps

func CollectNodesWithTimestamps(root Descendants) []*NodeWithTimestamps

CollectNodesWithTimestamps traverses the tree and collects all nodes with their timestamps

type TimestampRankable

type TimestampRankable struct {
	Node        *NodeWithTimestamps
	UseModified bool
}

TimestampRankable implements ranking by timestamp with formatting

func RankByCreated

func RankByCreated(nodes []*NodeWithTimestamps, topN int) []TimestampRankable

RankByCreated ranks nodes by creation date (oldest first)

func RankByModified

func RankByModified(nodes []*NodeWithTimestamps, topN int) []TimestampRankable

RankByModified ranks nodes by modification date (oldest first)

func (*TimestampRankable) GetRankingValue

func (r *TimestampRankable) GetRankingValue() int

func (*TimestampRankable) GetValue

func (r *TimestampRankable) GetValue() fmt.Stringer

func (TimestampRankable) String

func (r TimestampRankable) String() string

type UpdateNodeRequest added in v0.2.0

type UpdateNodeRequest struct {
	Name       *string `json:"name,omitempty"`
	Note       *string `json:"note,omitempty"`
	LayoutMode *string `json:"layoutMode,omitempty"`
}

UpdateNodeRequest represents the request body for nodes-update API

type UpdateNodeResponse added in v0.2.0

type UpdateNodeResponse struct {
	Status string `json:"status"`
}

UpdateNodeResponse represents the response from nodes-update API

type WorkflowyClient

type WorkflowyClient struct {
	*client.Client
	// contains filtered or unexported fields
}

WorkflowyClient wraps the generic Client with Workflowy-specific methods

func NewWorkflowyClient

func NewWorkflowyClient(opts ...client.Option) *WorkflowyClient

NewWorkflowyClient creates a new Workflowy API client

func (*WorkflowyClient) CompleteNode added in v0.3.0

func (wc *WorkflowyClient) CompleteNode(ctx context.Context, itemID string) (*UpdateNodeResponse, error)

func (*WorkflowyClient) CreateNode

CreateNode creates a new node in Workflowy

func (*WorkflowyClient) ExportNodes

func (wc *WorkflowyClient) ExportNodes(ctx context.Context) (*ExportNodesResponse, error)

ExportNodes retrieves all nodes from Workflowy (rate limited to 1 req/min)

func (*WorkflowyClient) ExportNodesWithCache

func (wc *WorkflowyClient) ExportNodesWithCache(ctx context.Context, forceRefresh bool) (*ExportNodesResponse, error)

ExportNodesWithCache retrieves all nodes using cache when valid forceRefresh bypasses cache and fetches fresh data

func (*WorkflowyClient) GetItem

func (wc *WorkflowyClient) GetItem(ctx context.Context, itemID string) (*Item, error)

GetItem retrieves an item by ID from Workflowy

func (*WorkflowyClient) ListChildren

func (wc *WorkflowyClient) ListChildren(ctx context.Context, itemID string) (*ListChildrenResponse, error)

ListChildren retrieves direct children of an item from Workflowy Use itemID "None" to get root level items

func (*WorkflowyClient) ListChildrenRecursive

func (wc *WorkflowyClient) ListChildrenRecursive(ctx context.Context, itemID string) (*ListChildrenResponse, error)

ListChildrenRecursive retrieves children recursively, building a complete tree Use itemID "None" to get the entire outline tree Uses default depth of 5 levels

func (*WorkflowyClient) ListChildrenRecursiveWithDepth

func (wc *WorkflowyClient) ListChildrenRecursiveWithDepth(ctx context.Context, itemID string, depth int) (*ListChildrenResponse, error)

ListChildrenRecursiveWithDepth retrieves children recursively up to specified depth Use itemID "None" to get the entire outline tree depth parameter controls how many levels deep to fetch (0 = no children, 1 = direct children only, etc.)

func (*WorkflowyClient) UncompleteNode added in v0.3.0

func (wc *WorkflowyClient) UncompleteNode(ctx context.Context, itemID string) (*UpdateNodeResponse, error)

func (*WorkflowyClient) UpdateNode added in v0.2.0

func (wc *WorkflowyClient) UpdateNode(ctx context.Context, itemID string, req *UpdateNodeRequest) (*UpdateNodeResponse, error)

UpdateNode updates an existing node in Workflowy

Jump to

Keyboard shortcuts

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