import { type Maybe } from '@dereekb/util'; import { type ICalendarComponentName, type ICalendarParameterName, type ICalendarParameterValue, type ICalendarPropertyName, type ICalendarValue } from './icalendar'; import { type ICalendar, type ICalendarAlarm, type ICalendarAttendee, type ICalendarDateTimeValue, type ICalendarEvent, type ICalendarExtraProperty, type ICalendarOrganizer, type ICalendarSerializeConfig, type ICalendarTimezone, type ICalendarTimezoneTransition } from './icalendar.model'; /** * A single already-encoded parameter on a content line. */ export interface ICalendarContentLineParameter { readonly name: ICalendarParameterName; /** * The already-encoded parameter value. See iCalendarParameterValue(). */ readonly value: ICalendarParameterValue; } /** * A single already-encoded property of a component, independent of the serialization format. * * This is the unit both an ICS emitter and any future jCal/xCal emitter consume: the value has been encoded * for its value type, but nothing about line assembly, folding or line endings has happened yet. */ export interface ICalendarContentLine { readonly name: ICalendarPropertyName; readonly parameters?: Maybe; /** * The already-encoded value. */ readonly value: ICalendarValue; } /** * A component in the intermediate tree. I.E. a VCALENDAR containing VEVENTs, each containing VALARMs. * * The tree is the serialization seam: {@link iCalendarToComponent} builds it from the domain model without * any knowledge of ICS, and a format emitter turns it into a string without any knowledge of the domain model. */ export interface ICalendarComponent { readonly name: ICalendarComponentName; readonly lines: readonly ICalendarContentLine[]; readonly components?: Maybe; } /** * Builds a content line. * * @param name - The property name. * @param value - The already-encoded property value. * @param parameters - Optional already-encoded parameters. * @returns The content line. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarContentLine(name: ICalendarPropertyName, value: ICalendarValue, parameters?: Maybe): ICalendarContentLine; /** * Encodes a date-time value as the value plus parameters of a content line. * * @param name - The property name. I.E. DTSTART. * @param value - The date-time to encode. * @returns The content line. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarDateTimeContentLine(name: ICalendarPropertyName, value: ICalendarDateTimeValue): ICalendarContentLine; /** * Converts an attendee or organizer into a content line. * * @param name - The property name. I.E. ATTENDEE or ORGANIZER. * @param attendee - The participant to encode. * @returns The content line. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarAttendeeContentLine(name: ICalendarPropertyName, attendee: ICalendarAttendee | ICalendarOrganizer): ICalendarContentLine; /** * The shape a {@link ICalendarExtraProperty} name must have to be a legal RFC 5545 property name. */ export declare const ICALENDAR_PROPERTY_NAME_REGEX: RegExp; /** * Converts an extra property into a content line, escaping its value as TEXT. * * @param property - The extra property to encode. * @returns The content line. * @throws {Error} If the property name is not a legal RFC 5545 property name. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarExtraPropertyContentLine(property: ICalendarExtraProperty): ICalendarContentLine; /** * The description RFC 5545 requires on a DISPLAY or EMAIL alarm that carries none of its own. */ export declare const DEFAULT_ICALENDAR_ALARM_DESCRIPTION = "Reminder"; /** * Converts an alarm into a VALARM component. * * @param alarm - The alarm to convert. * @returns The VALARM component. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarAlarmToComponent(alarm: ICalendarAlarm): ICalendarComponent; /** * Converts a timezone transition into a STANDARD or DAYLIGHT component. * * @param transition - The transition to convert. * @returns The sub-component. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarTimezoneTransitionToComponent(transition: ICalendarTimezoneTransition): ICalendarComponent; /** * Converts a timezone into a VTIMEZONE component. * * @param timezone - The timezone to convert. * @returns The VTIMEZONE component. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarTimezoneToComponent(timezone: ICalendarTimezone): ICalendarComponent; /** * Converts an event into a VEVENT component. * * Properties are emitted in a fixed canonical order so identical input yields byte-identical output. * * @param event - The event to convert. * @param timestamp - The DTSTAMP to use when the event carries none of its own. * @returns The VEVENT component. * @throws {Error} If the event has no UID, which clients silently drop. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarEventToComponent(event: ICalendarEvent, timestamp: Date): ICalendarComponent; /** * Converts a calendar into its component tree. * * THE SERIALIZATION SEAM. This function is format-agnostic: it knows the RFC 5545 data model (component * names, property names, value encodings) but nothing about how those are written out. An ICS emitter, and * any future jCal (RFC 7265) or xCal (RFC 6321) emitter, all consume this same tree. * * Properties are emitted in a fixed canonical order and no object keys are iterated, so identical input * yields byte-identical output. That lets a publisher content-hash the payload and skip a no-op write. * * @param calendar - The calendar to convert. * @param config - Optional serialization config, notably the DTSTAMP source. * @returns The VCALENDAR component. * * @__NO_SIDE_EFFECTS__ */ export declare function iCalendarToComponent(calendar: ICalendar, config?: Maybe): ICalendarComponent;