1 import type { CalendarNotificationSettings } from '@proton/shared/lib/interfaces/calendar/Calendar';
8 EVENT_VERIFICATION_STATUS,
17 } from '../../calendar/constants';
18 import { SHARED_SIGNED_FIELDS } from '../../calendar/constants';
19 import type { API_CODES } from '../../constants';
20 import { pick } from '../../helpers/object';
21 import type { Address } from '../Address';
22 import type { Nullable } from '../utils';
23 import type { NotificationModel } from './Notification';
24 import type { VcalRrulePropertyValue, VcalVeventComponent } from './VcalModel';
26 export interface CalendarEventData {
27 Type: CALENDAR_CARD_TYPE;
29 Signature: string | null;
33 export interface CalendarPersonalEventData extends CalendarEventData {
37 export interface Attendee {
40 Status: ATTENDEE_STATUS_API;
41 UpdateTime: Nullable<number>;
44 export interface CalendarEventBlobData {
45 CalendarKeyPacket: Nullable<string>;
46 CalendarEvents: CalendarEventData[];
47 SharedKeyPacket: Nullable<string>;
48 AddressKeyPacket: Nullable<string>;
49 AddressID: Nullable<string>;
50 SharedEvents: CalendarEventData[];
51 Notifications?: Nullable<CalendarNotificationSettings[]>;
52 AttendeesEvents: CalendarEventData[];
53 Attendees: Attendee[];
56 export type CalendarEventBlobDataWithNotifications = Required<CalendarEventBlobData>;
58 export interface CalendarEventSharedData {
60 SharedEventID: string;
66 IsProtonProtonInvite: 1 | 0;
67 IsPersonalSingleEdit: boolean;
69 Color: Nullable<string> | undefined;
72 export interface CalendarEventMetadata {
74 StartTimezone: string;
78 RRule: Nullable<string>;
80 RecurrenceID: Nullable<number>;
84 export interface CalendarEvent extends CalendarEventSharedData, CalendarEventBlobData, CalendarEventMetadata {}
86 export interface CalendarEventWithoutBlob extends CalendarEventSharedData, CalendarEventMetadata {}
88 export interface SyncMultipleApiSuccessResponses {
91 Code: API_CODES.SINGLE_SUCCESS;
96 export interface FrequencyModel {
118 vcalRruleValue?: VcalRrulePropertyValue;
121 export interface DateTimeModel {
127 export interface OrganizerModel {
132 export interface AttendeeModel {
135 rsvp: ICAL_ATTENDEE_RSVP;
136 role: ICAL_ATTENDEE_ROLE;
137 partstat: ICAL_ATTENDEE_STATUS;
141 export interface CalendarViewModel {
145 isSubscribed: boolean;
151 export interface CalendarsModel {
156 isSubscribed: boolean;
162 export interface EventModelView {
164 frequencyModel: FrequencyModel;
170 start: DateTimeModel;
172 attendees: AttendeeModel[];
173 organizer?: OrganizerModel;
174 isOrganizer: boolean; // this property only takes into account the event ICS content. It does not care if the event is in a shared or subscribed calendar
175 isAttendee: boolean; // this property only takes into account the event ICS content. It does not care if the event is in a shared or subscribed calendar
176 isProtonProtonInvite: boolean;
177 hasDefaultNotifications: boolean;
178 selfAttendeeIndex?: number;
179 selfAddress?: Address;
180 status: ICAL_EVENT_STATUS;
181 verificationStatus: EVENT_VERIFICATION_STATUS;
182 conferenceId?: string;
183 conferenceUrl?: string;
184 conferencePassword?: string;
185 conferenceHost?: string;
186 isConferenceTmpDeleted?: boolean;
190 export interface EventModel extends EventModelView {
191 // these types will be used in the future, for now only event is used
192 type: 'event' | 'alarm' | 'task';
193 calendar: CalendarViewModel;
194 calendars: CalendarsModel[];
200 defaultPartDayNotification: NotificationModel;
201 defaultFullDayNotification: NotificationModel;
202 fullDayNotifications: NotificationModel[];
203 partDayNotifications: NotificationModel[];
206 defaultEventDuration: number;
207 hasTouchedRrule: boolean;
208 hasPartDayDefaultNotifications: boolean;
209 hasFullDayDefaultNotifications: boolean;
212 export interface EventModelErrors {
222 participantError?: boolean;
225 export interface EventModelReadView extends EventModelView {
226 notifications?: NotificationModel[];
230 const sharedPick = (x: VcalVeventComponent) => pick(x, [...SHARED_SIGNED_FIELDS, 'component']);
231 export type SharedVcalVeventComponent = ReturnType<typeof sharedPick>;