2022-05-18 18:05:49 -03:00
|
|
|
import type { Prisma, DestinationCalendar, SelectedCalendar } from "@prisma/client";
|
2022-03-23 19:00:30 -03:00
|
|
|
import type { Dayjs } from "dayjs";
|
|
|
|
import type { calendar_v3 } from "googleapis";
|
|
|
|
import type { Time } from "ical.js";
|
|
|
|
import type { TFunction } from "next-i18next";
|
2022-06-09 21:32:34 -03:00
|
|
|
|
|
|
|
import type { Frequency } from "@calcom/prisma/zod-utils";
|
2022-01-06 14:28:31 -03:00
|
|
|
|
2022-03-23 19:00:30 -03:00
|
|
|
import type { Ensure } from "./utils";
|
2022-01-06 14:28:31 -03:00
|
|
|
|
2022-08-10 21:53:05 -03:00
|
|
|
export type { VideoCallData } from "./VideoApiAdapter";
|
|
|
|
|
2022-06-06 14:49:56 -03:00
|
|
|
type PaymentInfo = {
|
|
|
|
link?: string | null;
|
|
|
|
reason?: string | null;
|
|
|
|
id?: string | null;
|
|
|
|
};
|
|
|
|
|
2022-01-06 14:28:31 -03:00
|
|
|
export type Person = {
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
timeZone: string;
|
2022-01-27 17:32:53 -03:00
|
|
|
language: { translate: TFunction; locale: string };
|
2022-04-14 18:25:24 -03:00
|
|
|
username?: string;
|
2022-10-18 16:41:50 -03:00
|
|
|
id?: number;
|
|
|
|
bookingId?: number;
|
|
|
|
locale?: string;
|
2022-01-06 14:28:31 -03:00
|
|
|
};
|
|
|
|
|
2023-02-27 17:45:40 -03:00
|
|
|
export type TeamMember = {
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
timeZone: string;
|
|
|
|
language: { translate: TFunction; locale: string };
|
|
|
|
};
|
|
|
|
|
2022-09-07 16:28:43 -03:00
|
|
|
export type EventBusyDate = {
|
|
|
|
start: Date | string;
|
|
|
|
end: Date | string;
|
|
|
|
source?: string | null;
|
|
|
|
};
|
2022-03-23 19:00:30 -03:00
|
|
|
|
2022-08-03 04:19:16 -03:00
|
|
|
export type EventBusyDetails = EventBusyDate & {
|
|
|
|
title?: string;
|
2022-09-07 16:28:43 -03:00
|
|
|
source?: string | null;
|
2022-08-03 04:19:16 -03:00
|
|
|
};
|
|
|
|
|
2022-03-23 19:00:30 -03:00
|
|
|
export type CalendarServiceType = typeof Calendar;
|
2022-11-22 17:44:08 -03:00
|
|
|
export type AdditionalInfo = Record<string, unknown> & { calWarnings?: string[] };
|
2022-03-23 19:00:30 -03:00
|
|
|
|
|
|
|
export type NewCalendarEventType = {
|
|
|
|
uid: string;
|
|
|
|
id: string;
|
|
|
|
type: string;
|
|
|
|
password: string;
|
|
|
|
url: string;
|
2022-11-22 17:44:08 -03:00
|
|
|
additionalInfo: AdditionalInfo;
|
2022-03-23 19:00:30 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
export type CalendarEventType = {
|
|
|
|
uid: string;
|
|
|
|
etag: string;
|
|
|
|
/** This is the actual caldav event url, not the location url. */
|
|
|
|
url: string;
|
|
|
|
summary: string;
|
|
|
|
description: string;
|
|
|
|
location: string;
|
|
|
|
sequence: number;
|
|
|
|
startDate: Date | Dayjs;
|
|
|
|
endDate: Date | Dayjs;
|
|
|
|
duration: {
|
|
|
|
weeks: number;
|
|
|
|
days: number;
|
|
|
|
hours: number;
|
|
|
|
minutes: number;
|
|
|
|
seconds: number;
|
|
|
|
isNegative: boolean;
|
|
|
|
};
|
|
|
|
organizer: string;
|
|
|
|
attendees: any[][];
|
|
|
|
recurrenceId: Time;
|
|
|
|
timezone: any;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type BatchResponse = {
|
|
|
|
responses: SubResponse[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export type SubResponse = {
|
2022-05-11 17:47:42 -03:00
|
|
|
body: {
|
|
|
|
value: {
|
|
|
|
showAs: "free" | "tentative" | "away" | "busy" | "workingElsewhere";
|
|
|
|
start: { dateTime: string };
|
|
|
|
end: { dateTime: string };
|
|
|
|
}[];
|
|
|
|
};
|
2022-03-23 19:00:30 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
export interface ConferenceData {
|
|
|
|
createRequest?: calendar_v3.Schema$CreateConferenceRequest;
|
2022-01-06 14:28:31 -03:00
|
|
|
}
|
|
|
|
|
2022-06-06 16:49:00 -03:00
|
|
|
export interface AdditionalInformation {
|
2022-01-06 14:28:31 -03:00
|
|
|
conferenceData?: ConferenceData;
|
|
|
|
entryPoints?: EntryPoint[];
|
|
|
|
hangoutLink?: string;
|
|
|
|
}
|
|
|
|
|
2022-05-05 18:16:25 -03:00
|
|
|
export interface RecurringEvent {
|
|
|
|
dtstart?: Date | undefined;
|
2022-06-09 21:32:34 -03:00
|
|
|
interval: number;
|
|
|
|
count: number;
|
|
|
|
freq: Frequency;
|
2022-05-05 18:16:25 -03:00
|
|
|
until?: Date | undefined;
|
|
|
|
tzid?: string | undefined;
|
|
|
|
}
|
|
|
|
|
2022-10-12 02:29:04 -03:00
|
|
|
export interface BookingLimit {
|
|
|
|
PER_DAY?: number | undefined;
|
|
|
|
PER_WEEK?: number | undefined;
|
|
|
|
PER_MONTH?: number | undefined;
|
|
|
|
PER_YEAR?: number | undefined;
|
|
|
|
}
|
|
|
|
|
2022-10-19 13:11:50 -03:00
|
|
|
export type AppsStatus = {
|
|
|
|
appName: string;
|
2023-02-16 19:39:57 -03:00
|
|
|
type: (typeof App)["type"];
|
2022-10-19 13:11:50 -03:00
|
|
|
success: number;
|
|
|
|
failures: number;
|
2022-11-22 17:44:08 -03:00
|
|
|
errors: string[];
|
|
|
|
warnings?: string[];
|
2022-10-19 13:11:50 -03:00
|
|
|
};
|
|
|
|
|
2022-04-14 18:25:24 -03:00
|
|
|
// If modifying this interface, probably should update builders/calendarEvent files
|
2022-01-06 14:28:31 -03:00
|
|
|
export interface CalendarEvent {
|
|
|
|
type: string;
|
|
|
|
title: string;
|
|
|
|
startTime: string;
|
|
|
|
endTime: string;
|
2022-04-14 18:25:24 -03:00
|
|
|
organizer: Person;
|
|
|
|
attendees: Person[];
|
2022-04-07 15:22:11 -03:00
|
|
|
additionalNotes?: string | null;
|
2022-05-18 18:05:49 -03:00
|
|
|
customInputs?: Prisma.JsonObject | null;
|
2022-01-06 14:28:31 -03:00
|
|
|
description?: string | null;
|
|
|
|
team?: {
|
|
|
|
name: string;
|
2023-02-27 17:45:40 -03:00
|
|
|
members: TeamMember[];
|
2022-01-06 14:28:31 -03:00
|
|
|
};
|
|
|
|
location?: string | null;
|
|
|
|
conferenceData?: ConferenceData;
|
2022-06-06 16:49:00 -03:00
|
|
|
additionalInformation?: AdditionalInformation;
|
2022-01-06 14:28:31 -03:00
|
|
|
uid?: string | null;
|
|
|
|
videoCallData?: VideoCallData;
|
|
|
|
paymentInfo?: PaymentInfo | null;
|
2022-06-17 06:02:29 -03:00
|
|
|
requiresConfirmation?: boolean | null;
|
2022-01-06 14:28:31 -03:00
|
|
|
destinationCalendar?: DestinationCalendar | null;
|
2022-01-28 14:40:29 -03:00
|
|
|
cancellationReason?: string | null;
|
2022-02-09 15:25:58 -03:00
|
|
|
rejectionReason?: string | null;
|
2022-03-28 15:07:13 -03:00
|
|
|
hideCalendarNotes?: boolean;
|
2022-05-05 18:16:25 -03:00
|
|
|
recurrence?: string;
|
2022-06-09 21:32:34 -03:00
|
|
|
recurringEvent?: RecurringEvent | null;
|
2022-06-25 02:16:20 -03:00
|
|
|
eventTypeId?: number | null;
|
2022-10-19 13:11:50 -03:00
|
|
|
appsStatus?: AppsStatus[];
|
2022-10-18 16:41:50 -03:00
|
|
|
seatsShowAttendees?: boolean | null;
|
2023-01-31 18:14:19 -03:00
|
|
|
seatsPerTimeSlot?: number | null;
|
2023-03-02 15:15:28 -03:00
|
|
|
|
|
|
|
// It has responses to all the fields(system + user)
|
2023-03-07 14:50:54 -03:00
|
|
|
responses?: Record<
|
|
|
|
string,
|
|
|
|
{
|
|
|
|
value: string | string[];
|
|
|
|
label: string;
|
|
|
|
}
|
|
|
|
> | null;
|
2023-03-02 15:15:28 -03:00
|
|
|
|
|
|
|
// It just has responses to only the user fields. It allows to easily iterate over to show only user fields
|
2023-03-07 14:50:54 -03:00
|
|
|
userFieldsResponses?: Record<
|
|
|
|
string,
|
|
|
|
{
|
|
|
|
value: string | string[];
|
|
|
|
label: string;
|
|
|
|
}
|
|
|
|
> | null;
|
2022-01-06 14:28:31 -03:00
|
|
|
}
|
|
|
|
|
2022-03-23 19:00:30 -03:00
|
|
|
export interface EntryPoint {
|
|
|
|
entryPointType?: string;
|
|
|
|
uri?: string;
|
|
|
|
label?: string;
|
|
|
|
pin?: string;
|
|
|
|
accessCode?: string;
|
|
|
|
meetingCode?: string;
|
|
|
|
passcode?: string;
|
|
|
|
password?: string;
|
|
|
|
}
|
|
|
|
|
2022-06-06 16:49:00 -03:00
|
|
|
export interface AdditionalInformation {
|
2022-03-23 19:00:30 -03:00
|
|
|
conferenceData?: ConferenceData;
|
|
|
|
entryPoints?: EntryPoint[];
|
|
|
|
hangoutLink?: string;
|
|
|
|
}
|
|
|
|
|
2022-01-06 14:28:31 -03:00
|
|
|
export interface IntegrationCalendar extends Ensure<Partial<SelectedCalendar>, "externalId"> {
|
|
|
|
primary?: boolean;
|
|
|
|
name?: string;
|
2022-07-01 17:55:27 -03:00
|
|
|
readOnly?: boolean;
|
2022-12-20 18:50:20 -03:00
|
|
|
// For displaying the connected email address
|
|
|
|
email?: string;
|
2023-02-27 15:47:21 -03:00
|
|
|
primaryEmail?: string;
|
|
|
|
credentialId?: number;
|
|
|
|
integrationTitle?: string;
|
2022-01-06 14:28:31 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Calendar {
|
|
|
|
createEvent(event: CalendarEvent): Promise<NewCalendarEventType>;
|
|
|
|
|
2022-05-16 17:20:09 -03:00
|
|
|
updateEvent(
|
|
|
|
uid: string,
|
|
|
|
event: CalendarEvent,
|
|
|
|
externalCalendarId?: string | null
|
2022-06-17 15:34:41 -03:00
|
|
|
): Promise<NewCalendarEventType | NewCalendarEventType[]>;
|
2022-01-06 14:28:31 -03:00
|
|
|
|
2022-05-16 17:20:09 -03:00
|
|
|
deleteEvent(uid: string, event: CalendarEvent, externalCalendarId?: string | null): Promise<unknown>;
|
2022-01-06 14:28:31 -03:00
|
|
|
|
|
|
|
getAvailability(
|
|
|
|
dateFrom: string,
|
|
|
|
dateTo: string,
|
|
|
|
selectedCalendars: IntegrationCalendar[]
|
|
|
|
): Promise<EventBusyDate[]>;
|
|
|
|
|
|
|
|
listCalendars(event?: CalendarEvent): Promise<IntegrationCalendar[]>;
|
|
|
|
}
|