idea-toolbox
Version:
IDEA's utility functions
249 lines (248 loc) • 8.19 kB
TypeScript
import { Resource } from './resource.model';
import { epochDateTime } from './epoch';
/**
* Represents an appointment (event) of a calendar.
*
* Table: `idea_appointments`.
*
* Indexes:
* - calendarId-startTime-index (LSI, all)
* - calendarId-masterAppointmentId-index (LSI, keys); to manage occurences
* - internalNotificationFiresOn-internalNotificationFiresAt-index (GSI); includes:
* internalNotificationProject, internalNotificationTeamId, internalNotificationUserId,
* notifications, title, startTime, endTime
*/
export declare class Appointment extends Resource {
/**
* The id of the appointment.
* In case of external calendar, it's the external id; otherwise (local calendars), it's a IUID.
*/
appointmentId: string;
/**
* The id of the calendar owning the appointment.
* For external calendars, it's the direct id of the external calendar (and not the id of `idea_calendars`),
* to avoid repetitions of appointments for each copy of the external calendar linked to an IDEA calendar.
*/
calendarId: string;
/**
* A unique id for the appointment, shared across different calendars and calendaring systems (standard RFC5545);
* i.e. each appointment in different calendars may have different `appointmentId`, but it always have same `iCalUID`.
* Note: in many calendaring systems recurring events share the same `iCalUID`.
*/
iCalUID: string;
/**
* Master appointment id (optional): the id of the master appointment, in case this is an occurence.
*/
masterAppointmentId?: string;
/**
* The title of the appointment.
*/
title: string;
/**
* The location of the appointment.
*/
location: string;
/**
* The description of the appointment.
*/
description: string;
/**
* The starting time of the appointment.
*/
startTime: epochDateTime;
/**
* The ending time of the appointment.
*/
endTime: epochDateTime;
/**
* If true, it's an all-day event.
*/
allDay: boolean;
/**
* The timezone for the appointent start and end.
*/
timezone: string;
/**
* In case the calendar is linked to external services, the link to access the external resource.
*/
linkToOrigin?: string;
/**
* A list of objects linked to the appointment.
*/
linkedTo?: AppointmentLinkedObject[];
/**
* The attendees supposed to partecipate to the event.
* It's an empty array in case the appointment is "private", i.e. the creator is the only attendee.
*/
attendees: AppointmentAttendee[];
/**
* The appointment notifications and the specs for their execution.
* These may come from external calendars: in that case no internal notifications will fire.
* Note on notifications from external services.
* - Microsoft: up to 1 notification, max 1 week before;
* - Google: up to 5 notifications; max 4 weeks before;
* - Multiple notifications at the same time are not allowed.
*/
notifications: AppointmentNotification[];
/**
* Date and hour in which the reminder is slotted (`YYYYMMDDHH`). Avoid timezones: UTC!!
* Used to quickly identify the reminders to manage in a particular time frame.
* In case of appointments on external calendars these will not be valued.
*/
internalNotificationFiresOn?: string;
/**
* Fine grain time of alert, expressed in minutes.
* In case of appointments on external calendars these will not be valued.
*/
internalNotificationFiresAt?: number;
/**
* Project from which the notification comes; useful to get the notification preferences.
* In case of appointments on external calendars these will not be valued.
*/
internalNotificationProject?: string;
/**
* Team of the user that need to be notified; useful to get the notification preferences.
* In case of appointments on external calendars these will not be valued.
*/
internalNotificationTeamId?: string;
/**
* User that need to be notified; useful to get the notification preferences.
* In case of appointments on external calendars these will not be valued.
*/
internalNotificationUserId?: string;
load(x: any): void;
/**
* Set a default start/end day for all-day events, to be compatible with external services.
*/
fixAllDayTime(): void;
safeLoad(newData: any, safeData: any): void;
validate(): string[];
/**
* Helper to remove duplicates notifications for the same appointment.
*/
protected removeDuplicateNotifications(): void;
/**
* Calculate the firing time for internal appointments.
*/
calculateFiringTime(): void;
/**
* Get the information on an attendee.
* The latter can be identified by email or, by default, as the attendee marked as `self`.
*/
getAttendee(email?: string): AppointmentAttendee;
/**
* Get the attendance of the desired attendee.
* The latter can be identified by email or, by default, as the attendee marked as `self`.
*/
getAttendance(email?: string): AppointmentAttendance;
/**
* Whether the user is the organizer of the event.
* The user can be identified by email or, by default, as the attendee marked as `self`.
*/
isOrganizer(email?: string): boolean;
}
/**
* A brief view of the appointment, composed by only its keys.
*/
export declare class AppointmentKeys extends Resource {
/**
* The id of the appointment.
* In case of external calendar, it's the external id; otherwise (local calendars), it's a IUID.
*/
appointmentId: string;
/**
* The id of the calendar owning the appointment.
* For external calendars, it's the direct id of the external calendar (and not the id of `idea_calendars`),
* to avoid repetitions of appointments for each copy of the external calendar linked to an IDEA calendar.
*/
calendarId: string;
/**
* The id of the team, in case it's a shared calendar.
*/
teamId?: string;
load(x: any): void;
validate(): string[];
}
/**
* A generic structure to reference to a linked object.
*/
export declare class AppointmentLinkedObject extends Resource {
/**
* The type of the referenced object.
*/
type: AppointmentLinkedObjectTypes;
/**
* The id of the referenced object.
*/
id: string;
load(x: any): void;
validate(): string[];
}
/**
* The linked object types.
*/
export declare enum AppointmentLinkedObjectTypes {
SCARLETT_ACTIVITY = 100,
ARTHUR_ACTIVITY = 200
}
/**
* The info about the attendee to an appointment.
*/
export declare class AppointmentAttendee extends Resource {
/**
* The email to identify the attendee.
*/
email: string;
/**
* Whether the user identified by the email is the organizer of the event.
*/
organizer: boolean;
/**
* Whether this attendee record refers to the current user.
*/
self: boolean;
/**
* The attendance status.
*/
attendance: AppointmentAttendance;
load(x: any): void;
}
/**
* Possible attendance status for the appointment.
*/
export declare enum AppointmentAttendance {
DECLINED = -1,
NEEDS_ACTION = 0,
TENTATIVE = 1,
ACCEPTED = 2
}
/**
* The info about the appointment notification.
*/
export declare class AppointmentNotification extends Resource {
/**
* The method of the notification.
*/
method: AppointmentNotificationMethods;
/**
* The number of minutes before the event start time that the reminder occurs.
*/
minutes: number;
load(x: any): void;
}
/**
* Possible notification methods (currently supported for Google Calendars and internal calendars).
*/
export declare enum AppointmentNotificationMethods {
PUSH = "PUSH",
EMAIL = "EMAIL"
}
/**
* Possible notification units of time.
*/
export declare enum AppointmentNotificationUnitsOfTime {
MINUTES = "MINUTES",
HOURS = "HOURS",
DAYS = "DAYS",
WEEKS = "WEEKS"
}