import { AxiosHeaders } from 'axios'; interface CalDAVOptions { baseUrl: string; auth: AuthOptions; requestTimeout?: number; logRequests?: boolean; prodId?: string; headers?: AxiosHeaders; rejectUnauthorized?: boolean; } type AuthOptions = { type: "basic"; username: string; password: string; } | { type: "oauth"; accessToken: string; }; type SupportedComponent = "VEVENT" | "VTODO" | "VJOURNAL" | "VFREEBUSY" | "VTIMEZONE"; type RecurrenceRule = { freq?: "DAILY" | "WEEKLY" | "MONTHLY" | "YEARLY"; interval?: number; count?: number; until?: Date; wkst?: string; byday?: string[]; bymonthday?: number[]; bymonth?: number[]; }; type Alarm = { action: "DISPLAY"; trigger: string; description?: string; } | { action: "EMAIL"; trigger: string; description?: string; summary?: string; attendees: string[]; } | { action: "AUDIO"; trigger: string; }; interface EventRef { href: string; etag: string; } interface SyncChangesResult { changed: boolean; newCtag: string; newEvents: string[]; updatedEvents: string[]; deletedEvents: string[]; } interface Calendar { displayName: string; url: string; ctag?: string; supportedComponents: SupportedComponent[]; color?: string; } declare const EVENT_STATUSES: readonly ["TENTATIVE", "CONFIRMED", "CANCELLED"]; type EventStatus = (typeof EVENT_STATUSES)[number]; interface Event { uid: string; summary: string; start: Date; end: Date; description?: string; location?: string; status?: EventStatus; etag: string; href: string; wholeDay?: boolean; recurrenceRule?: RecurrenceRule; startTzid?: string; endTzid?: string; alarms?: Alarm[]; customFields?: Record; } type TodoRef = EventRef; interface SyncTodosResult { changed: boolean; newCtag: string; newTodos: string[]; updatedTodos: string[]; deletedTodos: string[]; } declare const TODO_STATUSES: readonly ["NEEDS-ACTION", "COMPLETED", "IN-PROCESS", "CANCELLED"]; type TodoStatus = (typeof TODO_STATUSES)[number]; interface Todo { uid: string; summary: string; start?: Date; due?: Date; completed?: Date; status?: TodoStatus; description?: string; location?: string; etag?: string; href: string; alarms?: Alarm[]; sortOrder?: number; customFields?: Record; } interface CalDAVClientCache { userPrincipal: string; calendarHome: string; prodId?: string; } type Omit = Pick>; type PartialBy = Omit & Partial>; declare class CalDAVClient { private options; private httpClient; private prodId; private parser; calendarHome: string | null; userPrincipal: string | null; requestTimeout: number; baseUrl: string; private constructor(); /** * Creates a new CalDAVClient instance and validates the provided credentials. * @param options - The CalDAV client options. * @returns A new CalDAVClient instance. * @throws An error if the provided credentials are invalid. * @example * ```typescript * const client = await CalDAVClient.create({ * baseUrl: "https://caldav.example.com", * username: "user", * password: "password", * }); * ``` */ static create(options: CalDAVOptions): Promise; /** * Creates a CalDAVClient instance from a cache object. * This is useful for restoring a client state without re-fetching the calendar home. * @param options - The CalDAV client options. * @param cache - The cached client state. * @return A new CalDAVClient instance initialized with the cached state. * @throws An error if the cache is invalid or incomplete. */ static createFromCache(options: CalDAVOptions, cache: CalDAVClientCache): CalDAVClient; getCalendarHome(): string | null; /** * Exports the current client state to a cache object. * This can be used to restore the client state later without re-fetching the calendar home. * @returns A CalDAVClientCache object containing the current client state. */ exportCache(): CalDAVClientCache; private tryDiscoveryRoots; private discover; getCalendars(): Promise; /** * Fetches all events from a specific calendar. * @param calendarUrl - The URL of the calendar to fetch events from. * @param options - Optional parameters for fetching events. * @returns An array of Event objects. */ getEvents(calendarUrl: string, options?: { start?: Date; end?: Date; all?: boolean; }): Promise; /** * Creates a new event in the specified calendar. * @param calendarUrl - The URL of the calendar to create the event in. * @param eventData - The data for the event to create. * @returns The created event's metadata. */ createEvent(calendarUrl: string, eventData: PartialBy): Promise<{ uid: string; href: string; etag: string; newCtag: string; }>; /** * Updates an existing event in the specified calendar. * @param calendarUrl - The URL of the calendar containing the event. * @param event - The event object with updated data. * @returns The updated event's metadata. */ updateEvent(calendarUrl: string, event: Event): Promise<{ uid: string; href: string; etag: string; newCtag: string; }>; deleteEvent(calendarUrl: string, eventUid: string, etag?: string): Promise; /** * Fetches all todos from a specific calendar. * @param calendarUrl - The URL of the calendar to fetch todos from. * @param options - Optional parameters for fetching todos. * @returns An array of Todo objects. */ getTodos(calendarUrl: string, options?: { start?: Date; end?: Date; all?: boolean; }): Promise; /** * Creates a new todo in the specified calendar. * @param calendarUrl - The URL of the calendar to create the todo in. * @param todoData - The data for the todo to create. * @returns The created todo's metadata. */ createTodo(calendarUrl: string, todoData: PartialBy): Promise<{ uid: string; href: string; etag: string; newCtag: string; }>; /** * Updates an existing todo in the specified calendar. * @param calendarUrl - The URL of the calendar containing the todo. * @param todo - The todo object with updated data. * @returns The updated todo's metadata. */ updateTodo(calendarUrl: string, todo: Todo): Promise<{ uid: string; href: string; etag: string; newCtag: string; }>; /** * Deletes a todo from the specified calendar. * @param calendarUrl - The URL of the calendar containing the todo. * @param todoUid - The UID of the todo to delete. * @param etag - Optional ETag for concurrency control. */ deleteTodo(calendarUrl: string, todoUid: string, etag?: string): Promise; /** * Fetches the current ETag for a given event href. * Useful when the server does not return an ETag on creation (e.g. Yahoo). * @param href - The full CalDAV event URL (ending in .ics). * @returns The ETag string, or throws an error if not found. */ getETag(href: string): Promise; /** * Fetches the current CTag for a given calendar URL. * @param calendarUrl - The URL of the calendar. * @returns The CTag string. */ getCtag(calendarUrl: string): Promise; private diffRefs; /** * Synchronizes changes between local events and remote calendar. * @param calendarUrl - The URL of the calendar to sync with. * @param ctag - The current CTag of the calendar. * @param localEvents - The local events to compare against remote. * @returns An object containing the sync results. */ syncChanges(calendarUrl: string, ctag: string, localEvents: EventRef[]): Promise; /** * Synchronizes changes between local todos and remote calendar. * @param calendarUrl - The URL of the calendar to sync with. * @param ctag - The current CTag of the calendar. * @param localTodos - The local todos to compare against remote. * @returns An object containing the sync results. */ syncTodoChanges(calendarUrl: string, ctag: string, localTodos: TodoRef[]): Promise; private getComponents; private buildICSData; private buildTodoICSData; private createItem; private updateItem; private deleteItem; private getItemRefs; getEventsByHref(calendarUrl: string, hrefs: string[]): Promise; getTodosByHref(calendarUrl: string, hrefs: string[]): Promise; private getItemsByHref; private absolutize; private resolveUrl; private getHrefFromProp; private isWeak; private cleanEtag; private propfind; private report; private mkIcsPut; private followRedirectOnce; } declare class CalDAVError extends Error { readonly status?: number | undefined; constructor(message: string, status?: number | undefined, options?: ErrorOptions); } export { type Alarm, CalDAVClient, CalDAVError, type CalDAVOptions, type Calendar, type Event, type RecurrenceRule, type Todo };