Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / shared / lib / interfaces / calendar / VcalModel.ts
blobb15ff4c8c505fad1c4b17c2418990dd5a857be2e
1 import type {
2     ICAL_ATTENDEE_ROLE,
3     ICAL_ATTENDEE_RSVP,
4     ICAL_ATTENDEE_STATUS,
5     ICAL_EVENT_STATUS,
6 } from '../../calendar/constants';
8 export enum VcalDays {
9     SU,
10     MO,
11     TU,
12     WE,
13     TH,
14     FR,
15     SA,
18 export type VcalDaysKeys = keyof typeof VcalDays;
20 export interface VcalDateValue {
21     year: number;
22     month: number;
23     day: number;
26 export interface VcalDateTimeValue {
27     year: number;
28     month: number;
29     day: number;
30     hours: number;
31     minutes: number;
32     seconds: number;
33     isUTC: boolean;
36 export type VcalDateOrDateTimeValue = VcalDateValue | VcalDateTimeValue;
38 export interface VcalDateTimeProperty {
39     parameters?: {
40         type?: 'date-time';
41         tzid?: string;
42     };
43     value: VcalDateTimeValue;
46 export interface VcalDateProperty {
47     parameters: {
48         type: 'date';
49     };
50     value: VcalDateValue;
53 export interface VcalFloatingDateTimeProperty {
54     parameters?: {
55         type?: 'date-time';
56     };
57     value: VcalDateTimeValue;
60 export interface IcalJSDateOrDateTimeProperty {
61     parameters?: {
62         type?: 'date' | 'date-time';
63         tzid?: string;
64     };
65     value: VcalDateValue | VcalDateTimeValue;
68 export type VcalDateOrDateTimeProperty = VcalDateProperty | VcalDateTimeProperty;
70 export type VcalRruleFreqValue = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY' | undefined | string;
71 export interface VcalRrulePropertyValue {
72     freq: VcalRruleFreqValue;
73     count?: number;
74     interval?: number;
75     until?: VcalDateOrDateTimeValue;
76     bysetpos?: number | number[];
77     byday?: string | string[];
78     bymonthday?: number | number[];
79     bymonth?: number | number[];
80     bysecond?: number | number[];
81     byminute?: number | number[];
82     byhour?: number | number[];
83     byyearday?: number | number[];
84     byweekno?: number | number[];
85     wkst?: VcalDaysKeys;
88 export interface VcalRruleProperty {
89     value: VcalRrulePropertyValue;
92 export interface VcalDurationValue {
93     weeks: number;
94     days: number;
95     hours: number;
96     minutes: number;
97     seconds: number;
98     isNegative: boolean;
101 export interface VcalTriggerRelativeProperty {
102     value: VcalDurationValue;
103     parameters?: {
104         type?: 'duration';
105         related?: string;
106     };
109 export type VcalTriggerProperty = VcalTriggerRelativeProperty | VcalDateTimeProperty;
111 export interface VcalUidProperty {
112     value: string;
115 export interface VcalStringProperty {
116     value: string;
119 export interface VcalStringProperyWithParams {
120     value: string;
121     parameters: { [key: string]: string };
124 export interface VcalNumberProperty {
125     value: number;
128 export interface VcalBooleanProperty {
129     value: 'true' | 'false';
130     parameters: { type: 'boolean' };
133 export interface VcalStringArrayProperty {
134     value: string[];
137 export interface VcalNumberArrayProperty {
138     value: number[];
141 interface VcalDurationProperty {
142     value: VcalDurationValue;
145 interface VcalURIProperty {
146     value: string;
147     params: { type: 'uri' };
150 interface VcalBinaryProperty {
151     value: string;
152     params: {
153         type: 'binary';
154         encoding: 'base64';
155     };
158 type VcalImageProperty = VcalURIProperty | VcalBinaryProperty;
160 export interface VcalValarmComponent<T = VcalTriggerProperty> {
161     component: 'valarm';
162     action: VcalStringProperty;
163     trigger: T;
164     duration?: VcalDurationProperty;
165     repeat?: VcalStringProperty;
166     description?: VcalStringProperty;
167     summary?: VcalStringProperty;
168     attendee?: VcalAttendeeProperty[];
169     attach?: VcalStringProperty;
172 export type VcalValarmRelativeComponent = VcalValarmComponent<VcalTriggerRelativeProperty>;
174 export type VcalValarmAbsoluteComponent = VcalValarmComponent<VcalDateTimeProperty>;
176 export interface VcalStringWithParamsProperty {
177     value: string;
178     params?: { [key: string]: string };
181 export interface VcalOrganizerPropertyParameters {
182     cn?: string;
183     dir?: string;
184     language?: string;
185     'sent-by'?: string;
186     email?: string;
189 export interface VcalOrganizerProperty {
190     value: string;
191     parameters?: VcalOrganizerPropertyParameters;
194 export interface VcalStatusProperty {
195     value: ICAL_EVENT_STATUS | string;
198 export interface VcalDescriptionPropertyParameters {
199     language?: string;
200     altrep?: string;
203 export interface VcalDescriptionProperty {
204     value: string;
205     parameters?: VcalDescriptionPropertyParameters;
208 export interface VcalAttendeePropertyParameters extends VcalOrganizerPropertyParameters {
209     cn?: string;
210     cutype?: string;
211     member?: string;
212     role?: ICAL_ATTENDEE_ROLE | string;
213     partstat?: ICAL_ATTENDEE_STATUS | string;
214     rsvp?: ICAL_ATTENDEE_RSVP | string;
215     'delegated-from'?: string;
216     'delegated-to'?: string;
217     'x-pm-token'?: string;
220 export interface VcalAttendeeProperty {
221     value: string;
222     parameters?: VcalAttendeePropertyParameters;
225 export interface VcalAttendeePropertyWithCn extends VcalAttendeeProperty {
226     parameters: VcalAttendeePropertyParameters & Required<Pick<VcalAttendeePropertyParameters, 'cn'>>;
229 export interface VcalAttendeePropertyWithPartstat extends VcalAttendeeProperty {
230     parameters: VcalAttendeePropertyParameters & Required<Pick<VcalAttendeePropertyParameters, 'partstat'>>;
233 export interface VcalAttendeePropertyWithRole extends VcalAttendeeProperty {
234     parameters: VcalAttendeePropertyParameters & Required<Pick<VcalAttendeePropertyParameters, 'role'>>;
237 export interface VcalAttendeePropertyWithToken extends VcalAttendeeProperty {
238     parameters: VcalAttendeePropertyParameters & Required<Pick<VcalAttendeePropertyParameters, 'x-pm-token'>>;
241 export type VcalPmAttendee = VcalAttendeePropertyWithCn & VcalAttendeePropertyWithToken;
243 export interface VcalCategoryProperty {
244     value: string[];
247 export interface VcalVeventComponent {
248     component: 'vevent';
249     components?: VcalValarmComponent[]; // Not complete. Can be other components.
250     uid: VcalUidProperty;
251     dtstamp: VcalDateTimeProperty;
252     dtstart: VcalDateOrDateTimeProperty;
253     dtend?: VcalDateOrDateTimeProperty;
254     rrule?: VcalRruleProperty;
255     'recurrence-id'?: VcalDateOrDateTimeProperty;
256     exdate?: VcalDateOrDateTimeProperty[];
257     organizer?: VcalOrganizerProperty;
258     attendee?: VcalAttendeeProperty[];
259     description?: VcalDescriptionProperty;
260     summary?: VcalStringProperty;
261     duration?: VcalDurationProperty;
262     location?: VcalDescriptionProperty;
263     geo?: VcalNumberArrayProperty;
264     class?: VcalStringProperty;
265     priority?: VcalNumberProperty;
266     sequence?: VcalNumberProperty;
267     status?: VcalStatusProperty;
268     created?: VcalDateTimeProperty;
269     'last-modified'?: VcalDateTimeProperty;
270     transp?: VcalStringProperty;
271     url?: VcalStringProperty;
272     attach?: VcalStringWithParamsProperty[];
273     categories?: VcalCategoryProperty[];
274     comment?: VcalStringWithParamsProperty[];
275     contact?: VcalStringWithParamsProperty[];
276     'request-status'?: VcalStringArrayProperty[];
277     'related-to'?: VcalStringWithParamsProperty[];
278     resources?: VcalStringWithParamsProperty[];
279     rdate?: VcalDateTimeProperty[];
280     'x-pm-proton-reply'?: VcalBooleanProperty;
281     'x-pm-session-key'?: VcalStringProperty;
282     'x-pm-shared-event-id'?: VcalStringProperty;
283     'x-yahoo-yid'?: VcalStringProperty;
284     'x-yahoo-user-status'?: VcalStringProperty;
285     'x-pm-conference-id'?: VcalStringProperyWithParams;
286     'x-pm-conference-url'?: VcalStringProperyWithParams;
287     color?: VcalStringProperty;
290 export type VcalComponentKeys = keyof VcalVeventComponent;
292 export interface VcalPmVeventComponent extends Omit<VcalVeventComponent, 'attendee'> {
293     attendee?: VcalAttendeePropertyWithToken[];
296 export interface VcalVtodoComponent {
297     component: 'vtodo';
298     components?: VcalValarmComponent[]; // Not complete. Can be other components.
299     uid: VcalUidProperty;
302 export interface VcalVjournalComponent {
303     component: 'vjournal';
304     components?: VcalValarmComponent[]; // Not complete. Can be other components.
305     uid: VcalUidProperty;
308 export interface VcalFreeBusyStartEndValue {
309     start: VcalDateTimeValue;
310     end: VcalDateTimeValue;
313 export interface VcalFreeBusyStartDurationValue {
314     start: VcalDateTimeValue;
315     duration: VcalDurationValue;
318 type VcalFreeBusyValue = VcalFreeBusyStartEndValue | VcalFreeBusyStartDurationValue;
320 export interface VcalFreeBusyProperty {
321     value: VcalFreeBusyValue[];
324 export interface VcalVfreebusyComponent {
325     component: 'vfreebusy';
326     components?: VcalValarmComponent[]; // Not complete. Can be other components.
327     uid: VcalUidProperty;
328     dtstamp: VcalDateTimeProperty;
329     dtstart?: VcalDateOrDateTimeProperty;
330     dtend?: VcalDateOrDateTimeProperty;
331     organizer?: VcalOrganizerProperty;
332     attendee?: VcalAttendeeProperty[];
333     freebusy?: VcalFreeBusyProperty[];
334     url?: VcalStringProperty;
335     comment?: VcalStringProperty[];
338 export interface VcalVtimezoneComponent {
339     component: 'vtimezone';
340     tzid: VcalStringProperty;
343 export interface VcalXOrIanaComponent {
344     component: string;
347 export type VcalCalendarComponent =
348     | VcalVeventComponent
349     | VcalVtodoComponent
350     | VcalVjournalComponent
351     | VcalVfreebusyComponent
352     | VcalVtimezoneComponent
353     | VcalXOrIanaComponent
354     | VcalVcalendar;
356 export interface VcalErrorComponent {
357     error: Error;
358     icalComponent: any;
361 export interface VcalVcalendar {
362     component: string;
363     components?: (
364         | VcalVeventComponent
365         | VcalVtodoComponent
366         | VcalVjournalComponent
367         | VcalVfreebusyComponent
368         | VcalVtimezoneComponent
369         | VcalXOrIanaComponent
370     )[];
371     prodid: VcalStringProperty;
372     version: VcalStringProperty;
373     calscale?: VcalStringProperty;
374     method?: VcalStringProperty;
375     'x-wr-timezone'?: VcalStringProperty;
376     'x-wr-calname'?: VcalStringProperty;
377     // RFC 7986
378     name?: VcalStringProperty;
379     description?: VcalStringProperty;
380     uid?: VcalStringProperty;
381     url?: VcalStringProperty;
382     'last-modified'?: VcalDateTimeProperty;
383     categories?: VcalStringWithParamsProperty[];
384     'refresh-interval'?: VcalDurationProperty;
385     source?: VcalURIProperty;
386     color?: VcalStringProperty;
387     image?: VcalImageProperty;
388     conference?: VcalURIProperty;
391 export interface VcalVeventComponentWithMaybeErrors extends Omit<VcalVeventComponent, 'components'> {
392     components?: (VcalErrorComponent | VcalValarmComponent)[];
395 export interface VcalVtodoComponentWithMaybeErrors extends Omit<VcalVtodoComponent, 'components'> {
396     components?: (VcalErrorComponent | VcalValarmComponent)[];
399 export interface VcalVjournalComponentWithMaybeErrors extends Omit<VcalVjournalComponent, 'components'> {
400     components?: (VcalErrorComponent | VcalValarmComponent)[];
403 export interface VcalVfreebusyComponentWithMaybeErrors extends Omit<VcalVfreebusyComponent, 'components'> {
404     components?: (VcalErrorComponent | VcalValarmComponent)[];
407 export type VcalCalendarComponentWithMaybeErrors =
408     | VcalVeventComponentWithMaybeErrors
409     | VcalVtodoComponentWithMaybeErrors
410     | VcalVjournalComponentWithMaybeErrors
411     | VcalVfreebusyComponentWithMaybeErrors
412     | VcalVtimezoneComponent
413     | VcalXOrIanaComponent;
415 export interface VcalVcalendarWithMaybeErrors extends Omit<VcalVcalendar, 'components'> {
416     components?: (VcalCalendarComponentWithMaybeErrors | VcalErrorComponent)[];