caldav

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapDescription

func CapDescription(desc string, maxLen int) string

CapDescription returns the description capped at maxLen characters.

func EventToIcal

func EventToIcal(e *Event) string

EventToIcal serializes an Event to a full VCALENDAR string.

func TaskToIcal

func TaskToIcal(t *Task) string

TaskToIcal serializes a Task to a full VCALENDAR string.

Types

type Alarm

type Alarm struct {
	Trigger     string `json:"trigger"`
	Action      string `json:"action"`
	Description string `json:"description,omitempty"`
}

Alarm represents a VALARM component.

type Calendar

type Calendar struct {
	Href           string   `json:"href"`
	DisplayName    string   `json:"display_name"`
	Color          string   `json:"color,omitempty"`
	Description    string   `json:"description,omitempty"`
	ComponentTypes []string `json:"component_types,omitempty"`
}

Calendar represents a CalDAV calendar collection.

type Client

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

Client is a CalDAV HTTP client that supports PROPFIND, REPORT, PUT, DELETE, and MKCALENDAR operations.

func NewClient

func NewClient(cfg *Config) *Client

NewClient creates a CalDAV client from the given configuration.

func (*Client) DeleteEvent

func (c *Client) DeleteEvent(eventHref, etag string) error

DeleteEvent removes a VEVENT by href.

func (*Client) DeleteTask

func (c *Client) DeleteTask(taskHref, etag string) error

DeleteTask removes a VTODO by href.

func (*Client) FindEventByUID

func (c *Client) FindEventByUID(uid string) (*EventWithMeta, string, error)

FindEventByUID searches all calendars for an event with the given UID. Returns the event with metadata and the calendar href it was found in.

func (*Client) FindTaskByUID

func (c *Client) FindTaskByUID(uid string) (*TaskWithMeta, string, error)

FindTaskByUID searches all calendars for a task with the given UID. Returns the task with metadata and the calendar href it was found in.

func (*Client) GetEvent

func (c *Client) GetEvent(eventHref string) (*EventWithMeta, error)

GetEvent fetches a single VEVENT by its href.

func (*Client) GetTask

func (c *Client) GetTask(taskHref string) (*TaskWithMeta, error)

GetTask fetches a single VTODO by its href.

func (*Client) ListCalendars

func (c *Client) ListCalendars() ([]Calendar, error)

ListCalendars performs a PROPFIND to discover all calendar collections.

func (*Client) ListEvents

func (c *Client) ListEvents(calendarHref string) (*EventListResult, error)

ListEvents performs a REPORT calendar-query to list all VEVENTs in a calendar. Parse errors for individual events are collected in EventListResult.ParseErrors rather than causing the entire listing to fail.

func (*Client) ListTasks

func (c *Client) ListTasks(calendarHref string) (*TaskListResult, error)

ListTasks performs a REPORT calendar-query to list all VTODOs in a calendar. Parse errors for individual tasks are collected in TaskListResult.ParseErrors rather than causing the entire listing to fail.

All tasks are returned regardless of STATUS. Server-side filtering via prop-filter is deferred until incremental sync is implemented — the haustoria's status-tags mapping requires completed tasks during checkin. https://github.com/amarbel-llc/dodder/issues/87

func (*Client) MkCalendar

func (c *Client) MkCalendar(href, displayName, description string) error

MkCalendar creates a new calendar collection via MKCALENDAR.

func (*Client) PutEvent

func (c *Client) PutEvent(eventHref, icalData, etag string) error

PutEvent creates or updates a VEVENT at the given href.

func (*Client) PutTask

func (c *Client) PutTask(taskHref, icalData, etag string) error

PutTask creates or updates a VTODO at the given href.

type Config

type Config struct {
	URL      string
	Username string
	Password string
}

Config holds CalDAV connection parameters read from environment variables.

func ConfigFromEnv

func ConfigFromEnv() (*Config, error)

ConfigFromEnv reads CALDAV_URL, CALDAV_USERNAME, and CALDAV_PASSWORD from the environment. Returns an error if any required variable is missing.

type Event

type Event struct {
	UID          string   `json:"uid"`
	Summary      string   `json:"summary"`
	Description  string   `json:"description,omitempty"`
	Status       string   `json:"status,omitempty"`
	Location     string   `json:"location,omitempty"`
	Geo          string   `json:"geo,omitempty"`
	DtStart      string   `json:"dtstart,omitempty"`
	DtStartTZID  string   `json:"dtstart_tzid,omitempty"`
	DtEnd        string   `json:"dtend,omitempty"`
	DtEndTZID    string   `json:"dtend_tzid,omitempty"`
	Duration     string   `json:"duration,omitempty"`
	Organizer    string   `json:"organizer,omitempty"`
	Attendees    []string `json:"attendees,omitempty"`
	Categories   []string `json:"categories,omitempty"`
	RRule        string   `json:"rrule,omitempty"`
	RecurrenceID string   `json:"recurrence_id,omitempty"`
	Sequence     int      `json:"sequence,omitempty"`
	Transp       string   `json:"transp,omitempty"`
	Created      string   `json:"created,omitempty"`
	LastModified string   `json:"last_modified,omitempty"`

	// Derived fields
	Alarms            []Alarm `json:"alarms,omitempty"`
	HasDescription    bool    `json:"has_description"`
	DescriptionTokens int     `json:"description_tokens"`

	// Server metadata
	Href string `json:"href,omitempty"`
	ETag string `json:"etag,omitempty"`
}

Event is the structured representation of a VEVENT component.

func ParseVEVENT

func ParseVEVENT(raw string) (*Event, error)

ParseVEVENT parses a raw iCalendar string and extracts the first VEVENT as an Event.

func (*Event) ToMetadata

func (e *Event) ToMetadata() EventMetadata

ToMetadata converts a full Event to its lightweight metadata representation.

type EventListResult

type EventListResult struct {
	Events      []EventWithMeta
	ParseErrors []string
}

EventListResult holds the results of listing events, including any parse errors for individual events that could not be parsed.

type EventMetadata

type EventMetadata struct {
	UID               string   `json:"uid"`
	Summary           string   `json:"summary"`
	Status            string   `json:"status,omitempty"`
	DtStart           string   `json:"dtstart,omitempty"`
	DtEnd             string   `json:"dtend,omitempty"`
	Location          string   `json:"location,omitempty"`
	Categories        []string `json:"categories,omitempty"`
	RRule             string   `json:"rrule,omitempty"`
	HasDescription    bool     `json:"has_description"`
	DescriptionTokens int      `json:"description_tokens"`
}

EventMetadata is the lightweight tier-1 view of an event.

type EventWithMeta

type EventWithMeta struct {
	Event Event
	Raw   string
}

EventWithMeta pairs a parsed Event with its raw iCalendar text.

type Task

type Task struct {
	UID                string   `json:"uid"`
	Summary            string   `json:"summary"`
	Description        string   `json:"description,omitempty"`
	Status             string   `json:"status,omitempty"`
	Priority           int      `json:"priority,omitempty"`
	Due                string   `json:"due,omitempty"`
	DueTZID            string   `json:"due_tzid,omitempty"`
	DtStart            string   `json:"dtstart,omitempty"`
	DtStartTZID        string   `json:"dtstart_tzid,omitempty"`
	Completed          string   `json:"completed,omitempty"`
	Created            string   `json:"created,omitempty"`
	LastModified       string   `json:"last_modified,omitempty"`
	Categories         []string `json:"categories,omitempty"`
	PercentComplete    int      `json:"percent_complete,omitempty"`
	ParentUID          string   `json:"parent_uid,omitempty"`
	RecurrenceID       string   `json:"recurrence_id,omitempty"`
	RRule              string   `json:"rrule,omitempty"`
	Location           string   `json:"location,omitempty"`
	Geo                string   `json:"geo,omitempty"`
	SortOrder          int      `json:"sort_order,omitempty"`
	Sequence           int      `json:"sequence,omitempty"`
	Attachments        []string `json:"attachments,omitempty"`
	StructuredLocation string   `json:"structured_location,omitempty"`

	// Derived fields
	SubtaskUIDs       []string `json:"subtask_uids,omitempty"`
	Alarms            []Alarm  `json:"alarms,omitempty"`
	HasDescription    bool     `json:"has_description"`
	DescriptionTokens int      `json:"description_tokens"`

	// Server metadata
	Href string `json:"href,omitempty"`
	ETag string `json:"etag,omitempty"`
}

Task is the structured representation of a VTODO component, covering all fields that tasks.org uses.

func ParseVTODO

func ParseVTODO(raw string) (*Task, error)

ParseVTODO parses a raw iCalendar string and extracts the first VTODO as a Task. For recurring tasks (RRULE), a single .ics resource may contain multiple VTODO components: a master plus overrides with RECURRENCE-ID. This function returns only the first (master) VTODO. Override components are not extracted because dodder maps each CalDAV resource to one zettel — the recurring pattern is the conceptual unit, not individual instances.

func (*Task) ToMetadata

func (t *Task) ToMetadata() TaskMetadata

ToMetadata converts a full Task to its lightweight metadata representation.

type TaskListResult

type TaskListResult struct {
	Tasks       []TaskWithMeta
	ParseErrors []string
}

TaskListResult holds the results of listing tasks, including any parse errors for individual tasks that could not be parsed.

type TaskMetadata

type TaskMetadata struct {
	UID               string   `json:"uid"`
	Summary           string   `json:"summary"`
	Status            string   `json:"status,omitempty"`
	Priority          int      `json:"priority,omitempty"`
	Due               string   `json:"due,omitempty"`
	Categories        []string `json:"categories,omitempty"`
	RRule             string   `json:"rrule,omitempty"`
	HasDescription    bool     `json:"has_description"`
	DescriptionTokens int      `json:"description_tokens"`
	ParentUID         string   `json:"parent_uid,omitempty"`
	AttachmentCount   int      `json:"attachment_count,omitempty"`
	Location          string   `json:"location,omitempty"`
}

TaskMetadata is the lightweight tier-1 view of a task.

type TaskWithMeta

type TaskWithMeta struct {
	Task Task
	Raw  string
}

TaskWithMeta pairs a parsed Task with its raw iCalendar text.

Jump to

Keyboard shortcuts

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