cal.pub0.org/lib/types.ts

195 lines
4.8 KiB
TypeScript
Raw Normal View History

import { AppStoreLocationType, DefaultLocationType } from "@calcom/app-store/locations";
import {
User,
Team,
Credential,
SelectedCalendar,
2022-04-01 23:55:41 +00:00
EventTypeCustomInput,
Attendee,
Availability,
BookingReference,
Booking,
DailyEventReference,
Webhook,
DestinationCalendar,
Membership,
Payment,
Schedule,
2022-04-02 00:45:28 +00:00
ReminderMail,
EventType,
} from "@calcom/prisma/client";
2022-03-30 12:17:55 +00:00
// Base response, used for all responses
export type BaseResponse = {
message?: string;
error?: Error;
};
2022-03-30 12:17:55 +00:00
// User
export type UserResponse = BaseResponse & {
user?: Partial<User>;
2022-03-30 12:17:55 +00:00
};
2022-03-30 12:17:55 +00:00
export type UsersResponse = BaseResponse & {
users?: Partial<User>[];
2022-03-30 12:17:55 +00:00
};
// Team
export type TeamResponse = BaseResponse & {
team?: Partial<Team>;
owner?: Partial<Membership>;
};
export type TeamsResponse = BaseResponse & {
teams?: Partial<Team>[];
};
// SelectedCalendar
export type SelectedCalendarResponse = BaseResponse & {
selected_calendar?: Partial<SelectedCalendar>;
};
export type SelectedCalendarsResponse = BaseResponse & {
selected_calendars?: Partial<SelectedCalendar>[];
};
// Attendee
export type AttendeeResponse = BaseResponse & {
attendee?: Partial<Attendee>;
};
2022-04-08 01:16:53 +00:00
// Grouping attendees in booking arrays for now,
// later might remove endpoint and move to booking endpoint altogether.
export type AttendeesResponse = BaseResponse & {
attendees?: Partial<Attendee>[];
};
// Availability
export type AvailabilityResponse = BaseResponse & {
availability?: Partial<Availability>;
};
2022-04-04 19:53:03 +00:00
export type AvailabilitiesResponse = BaseResponse & {
availabilities?: Partial<Availability>[];
};
// BookingReference
export type BookingReferenceResponse = BaseResponse & {
booking_reference?: Partial<BookingReference>;
};
export type BookingReferencesResponse = BaseResponse & {
booking_references?: Partial<BookingReference>[];
};
// Booking
export type BookingResponse = BaseResponse & {
booking?: Partial<Booking>;
};
export type BookingsResponse = BaseResponse & {
bookings?: Partial<Booking>[];
};
// Credential
export type CredentialResponse = BaseResponse & {
credential?: Partial<Credential>;
};
export type CredentialsResponse = BaseResponse & {
credentials?: Partial<Credential>[];
};
// DailyEventReference
export type DailyEventReferenceResponse = BaseResponse & {
daily_event_reference?: Partial<DailyEventReference>;
};
export type DailyEventReferencesResponse = BaseResponse & {
daily_event_references?: Partial<DailyEventReference>[];
};
// DestinationCalendar
export type DestinationCalendarResponse = BaseResponse & {
destination_calendar?: Partial<DestinationCalendar>;
};
export type DestinationCalendarsResponse = BaseResponse & {
destination_calendars?: Partial<DestinationCalendar>[];
};
// Membership
export type MembershipResponse = BaseResponse & {
membership?: Partial<Membership>;
};
export type MembershipsResponse = BaseResponse & {
memberships?: Partial<Membership>[];
};
2022-04-01 23:55:41 +00:00
// EventTypeCustomInput
export type EventTypeCustomInputResponse = BaseResponse & {
event_type_custom_input?: Partial<EventTypeCustomInput>;
2022-04-01 23:55:41 +00:00
};
export type EventTypeCustomInputsResponse = BaseResponse & {
event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
2022-04-01 23:55:41 +00:00
};
// From rrule https://jakubroztocil.github.io/rrule freq
export enum Frequency {
"YEARLY",
"MONTHLY",
"WEEKLY",
"DAILY",
"HOURLY",
"MINUTELY",
"SECONDLY",
}
interface EventTypeExtended extends Omit<EventType, "recurringEvent" | "locations"> {
recurringEvent: {
dtstart?: Date | undefined;
interval?: number | undefined;
count?: number | undefined;
freq?: Frequency | undefined;
until?: Date | undefined;
tzid?: string | undefined;
2022-05-27 23:50:28 +00:00
} | null;
locations:
| {
link?: string | undefined;
address?: string | undefined;
hostPhoneNumber?: string | undefined;
type: DefaultLocationType | AppStoreLocationType;
}[]
| null;
}
2022-05-19 22:58:42 +00:00
// EventType
export type EventTypeResponse = BaseResponse & {
2022-05-20 01:40:14 +00:00
event_type?: Partial<EventType | EventTypeExtended>;
};
export type EventTypesResponse = BaseResponse & {
2022-05-20 01:40:14 +00:00
event_types?: Partial<EventType | EventTypeExtended>[];
};
// Payment
export type PaymentResponse = BaseResponse & {
payment?: Partial<Payment>;
};
export type PaymentsResponse = BaseResponse & {
payments?: Partial<Payment>[];
};
// Schedule
export type ScheduleResponse = BaseResponse & {
schedule?: Partial<Schedule>;
};
export type SchedulesResponse = BaseResponse & {
schedules?: Partial<Schedule>[];
};
// Webhook
export type WebhookResponse = BaseResponse & {
2022-05-20 19:52:41 +00:00
webhook?: Partial<Webhook> | null;
};
export type WebhooksResponse = BaseResponse & {
webhooks?: Partial<Webhook>[];
};
2022-04-02 00:45:28 +00:00
// ReminderMail
export type ReminderMailResponse = BaseResponse & {
reminder_mail?: Partial<ReminderMail>;
2022-04-02 00:45:28 +00:00
};
export type ReminderMailsResponse = BaseResponse & {
reminder_mails?: Partial<ReminderMail>[];
2022-04-02 00:45:28 +00:00
};