Skip to content
File

Blob: src/worker/caldav/ical/types.ts

typescript84 lines
1import type { CalendarComponentType } from "@/worker/db/types";
2 
3export interface RecurrenceBounds {
4 maxYears: number;
5 maxInstances: number;
6}
7 
8export interface CalendarTimeRange {
9 startMs: number | null;
10 endMs: number | null;
11 floatingTimeZone?: string | null;
12}
13 
14export type CalendarSearchFilter =
15 | { kind: "component"; component: CalendarComponentType }
16 | { kind: "uid"; text: string }
17 | { kind: "summary"; text: string }
18 | { kind: "property-text"; name: string; text: string }
19 | { kind: "property-defined"; name: string; defined: boolean }
20 | { kind: "time-range"; range: CalendarTimeRange };
21 
22export interface ParsedICalendar {
23 body: string;
24 size: number;
25 uid: string;
26 componentType: CalendarComponentType;
27 dtstartMs: number | null;
28 dtendMs: number | null;
29 dueMs: number | null;
30 completedMs: number | null;
31 summary: string | null;
32 hasRecurrence: boolean;
33 recurrenceMinMs: number | null;
34 recurrenceMaxMs: number | null;
35}
36 
37export interface ParsedProperty {
38 name: string;
39 params: Record<string, string>;
40 value: string;
41 rawLine: string;
42}
43 
44export interface DateValue {
45 ms: number;
46 raw: string;
47 valueType: "date" | "date-time";
48 floating: boolean;
49}
50 
51export interface ParsedComponent {
52 componentType: CalendarComponentType;
53 lines: string[];
54 properties: ParsedProperty[];
55 uid: string;
56 recurrenceId: DateValue | null;
57 floatingTimeZone: string | null;
58 dtstart: DateValue | null;
59 dtend: DateValue | null;
60 due: DateValue | null;
61 completed: DateValue | null;
62 created: DateValue | null;
63 durationMs: number | null;
64 summary: string | null;
65}
66 
67export interface ParsedCalendarDocument {
68 body: string;
69 size: number;
70 uid: string;
71 componentType: CalendarComponentType;
72 components: ParsedComponent[];
73 master: ParsedComponent | null;
74 overrides: ParsedComponent[];
75}
76 
77export interface CalendarOccurrence {
78 component: ParsedComponent;
79 originalStartMs: number;
80 startMs: number;
81 endMs: number;
82 isInitial: boolean;
83}