feat: add advanced tab attributes to api/v2/event-types (#16314)

* added bookerLayouts

* added requiresConfirmation

* added tests

* undo extra changes

* undo extra change

* fixed imports

* added requiresBookerEmailVerification

* added hideCalendarNotes

* added lockTimeZoneToggleOnBookingPage

* added eventTypeColor

* undo extra changes

* added seats

* added requiresConfirmationWillBlockSlot to requiresConfirmation

* refactor: Implement BaseEventType class to avoid duplication across EventType input/output classes

## D-R-Y ##

* temp-fix: will revert later

* Correct placement of users array from EventTypeOutput to TeamEventTypeOutput

* Refactor: Shifted transformation logic to controllers using interceptors and pipes for a cleaner service layer.

* small fix

* Refactor: Moved transformation logic from service to controller using interceptors and pipes

** organisations/event-types

* feat: adde tests for `validateEventTypeInputs`

* fix: failing test

* fix: layout validator

* renamed blockCalendarForUnconfirmedBookings to blockUnconfirmedBookingsInBooker

* testing changes

* added disabled state

* fix merege conflict

* renamed requiresConfirmation to confirmationPolicy

* renamed OutputEventTypesResponseInterceptor to OutputTeamEventTypesResponseInterceptor

* renamed `darkThemeColor` -> `darkThemeHex` and `lightThemeColor` -> `lightThemeHex`

* renamed `eventTypeColor` -> `color`

* changed `requiresConfirmation` -> `confirmationPolicy`

* added tests for disabled state

* added class-validators to `disabled?: false`

* Revert: Split create and update input/output classes

* feat: Refactor responses to use DTOs with plainToClass for explicit property control

	•	Updated all endpoints to return response DTOs (e.g., CreateTeamEventTypeOutput, GetTeamEventTypeOutput) to ensure consistent Swagger documentation generation.
	•	Introduced plainToClass for transforming responses, enabling explicit control over which properties are returned in the response, following Morgan’s recommendation.
	•	Replaced generic HandlerResponse type with class-validator based DTOs for each endpoint, ensuring TypeScript enforces correct response structure.
	•	Applied strategy: "excludeAll" to limit response properties to only those explicitly defined in the DTO, preventing unintended fields from being included in the API responses.

* added pipes to transform output data

* add clean script to platform-types package.json

* added customName

* added destination calendar

* fixed type errors

* added useDestinationCalendarEmail

* refactor: api-reqest and api-response

* Update event-type.output.ts

* fixed errors

* Update yarn.lock

* added some missed properties to output

* Update constants.ts

* removed return type

* fixed some type errors

* reuse types

* Improve readability of validation functions

* Update CHANGELOG.md

* chore: post publish platform libraries

* Update documentation.json

* fix: reset platform libraries to 0.0.0

* fixup! fix: reset platform libraries to 0.0.0

* Update event-type.tranformed.ts

---------

Co-authored-by: supalarry <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-09-24 13:36:05 +03:00
1 parent 6de454b071
commit 2e2a6c73b1
68 files changed
+2859 -6305

No files matched your search

@@ -0,0 +1,11 @@
export enum BookerLayoutsInputEnum_2024_06_14 {
month = "month",
week = "week",
column = "column",
}
export enum BookerLayoutsOutputEnum_2024_06_14 {
month_view = "month_view",
week_view = "week_view",
column_view = "column_view",
}
@@ -8,4 +8,5 @@ export enum BookingWindowPeriodOutputTypeEnum_2024_06_14 {
RANGE = "RANGE",
ROLLING_WINDOW = "ROLLING_WINDOW",
ROLLING = "ROLLING",
UNLIMITED = "UNLIMITED",
}
@@ -0,0 +1,9 @@
export enum ConfirmationPolicyEnum {
ALWAYS = "always",
TIME = "time",
}
export enum NoticeThresholdUnitEnum {
MINUTES = "minutes",
HOURS = "hours",
}
+2
View File
@@ -5,3 +5,5 @@ export * from "./event-types/interval-limits.enum";
export * from "./event-types/period-type";
export * from "./event-types/scheduling-type";
export * from "./event-types/frequency";
export * from "./event-types/booker-layouts.enum";
export * from "./event-types/confirmation-policy.enum";
+2
View File
@@ -5,3 +5,5 @@ export * from "./event-types/interval-limits.enum";
export * from "./event-types/period-type";
export * from "./event-types/scheduling-type";
export * from "./event-types/frequency";
export * from "./event-types/booker-layouts.enum";
export * from "./event-types/confirmation-policy.enum";
+18
View File
@@ -1,3 +1,21 @@
## 0.0.38
#### Feature: Added Support for AdvancedTab Event-Type Attributes in API
- **Booker Layouts**:
- Added `transformBookerLayoutsApiToInternal` translator to enable the `bookerLayouts` attribute in the event-type API.
- Added `transformBookerLayoutsInternalToApi` translator to improve clarity and readability of `bookerLayouts` response data.
- **Event-Type Colors**:
- Added `transformEventColorsApiToInternal` translator to enable the `color` attribute in the event-type API.
- Added `transformEventTypeColorsInternalToApi` translator to enhance the readability of the `color` attribute in the response.
- **Confirmation Policy**:
- Added `transformConfirmationPolicyApiToInternal` translator to enable the `confirmationPolicy` attribute in the event-type API.
- Added `transformRequiresConfirmationInternalToApi` translator to improve the readability of `requiresConfirmation` data in the response.
- **Seats**:
- Added `transformSeatsApiToInternal` translator to enable the `seats` attribute in the event-type API.
- Added `transformSeatsInternalToApi` translator to enhance readability and clarity of the `seats` data.
## 0.0.37
Released to support PR https://github.com/calcom/cal.com/pull/16200
+10 -1
View File
@@ -100,12 +100,20 @@ export {
transformIntervalLimitsApiToInternal,
transformFutureBookingLimitsApiToInternal,
transformRecurrenceApiToInternal,
transformBookerLayoutsApiToInternal,
transformConfirmationPolicyApiToInternal,
transformEventColorsApiToInternal,
transformSeatsApiToInternal,
// note(Lauris): Internal to api
transformBookingFieldsInternalToApi,
transformLocationsInternalToApi,
transformIntervalLimitsInternalToApi,
transformFutureBookingLimitsInternalToApi,
transformRecurrenceInternalToApi,
transformBookerLayoutsInternalToApi,
transformRequiresConfirmationInternalToApi,
transformEventTypeColorsInternalToApi,
transformSeatsInternalToApi,
// note(Lauris): schemas
TransformedLocationsSchema,
BookingFieldsSchema,
@@ -118,7 +126,7 @@ export {
export type { SystemField, CustomField } from "@calcom/lib/event-types/transformers";
export { parseBookingLimit } from "@calcom/lib";
export { parseBookingLimit, parseEventTypeColor } from "@calcom/lib";
export { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
export { dynamicEvent } from "@calcom/lib/defaultEvents";
@@ -133,3 +141,4 @@ export { getTranslation };
export { updateNewTeamMemberEventTypes } from "@calcom/lib/server/queries";
export { ErrorCode } from "@calcom/lib/errorCodes";
export { validateCustomEventName } from "@calcom/core/event";
@@ -1,2 +1,3 @@
export * from "./inputs";
export * from "./outputs";
export * from "./transformed";
@@ -0,0 +1,52 @@
import type { ValidatorConstraintInterface, ValidationOptions } from "class-validator";
import { ValidatorConstraint, registerDecorator } from "class-validator";
import {
BookerLayoutsInputEnum_2024_06_14,
type BookerLayoutsOutputEnum_2024_06_14,
} from "@calcom/platform-enums";
export type BookerLayoutsTransformedSchema = {
defaultLayout: BookerLayoutsOutputEnum_2024_06_14;
enabledLayouts: BookerLayoutsOutputEnum_2024_06_14[];
};
@ValidatorConstraint({ name: "LayoutValidator", async: false })
export class LayoutValidator implements ValidatorConstraintInterface {
validate(value: BookerLayoutsInputEnum_2024_06_14 | BookerLayoutsInputEnum_2024_06_14[]) {
const validValues = Object.values(BookerLayoutsInputEnum_2024_06_14);
// If the value is an array, check if every item in the array is valid
if (Array.isArray(value)) {
return value.every((layout) => validValues.includes(layout));
}
// If the value is a single layout, check if it is valid
return validValues.includes(value);
}
defaultMessage() {
const validValues = Object.values(BookerLayoutsInputEnum_2024_06_14).join(", ");
return `Invalid layout. Valid options are: ${validValues}`;
}
}
function IsValidLayout(validationOptions?: ValidationOptions) {
return function (object: any, propertyName: string) {
registerDecorator({
name: "IsValidLayout",
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
validator: new LayoutValidator(),
});
};
}
export class BookerLayouts_2024_06_14 {
@IsValidLayout({ message: "defaultLayout must be one of the valid layouts." })
defaultLayout!: BookerLayoutsInputEnum_2024_06_14;
@IsValidLayout({ message: "enabledLayouts must be one of the valid layouts." })
enabledLayouts!: BookerLayoutsInputEnum_2024_06_14[];
}
@@ -1,6 +1,8 @@
import { ApiProperty } from "@nestjs/swagger";
import type { ValidatorConstraintInterface, ValidationOptions } from "class-validator";
import { IsInt, IsOptional, Min, ValidatorConstraint, registerDecorator } from "class-validator";
import { IsBoolean, IsInt, IsOptional, Min, ValidatorConstraint, registerDecorator } from "class-validator";
import type { Disabled_2024_06_14 } from "./disabled.input";
export type BookingLimitsKeyOutputType_2024_06_14 = "PER_DAY" | "PER_WEEK" | "PER_MONTH" | "PER_YEAR";
export type BookingLimitsKeysInputType = "day" | "week" | "month" | "year";
@@ -8,7 +10,7 @@ export type TransformBookingLimitsSchema_2024_06_14 = {
[K in BookingLimitsKeyOutputType_2024_06_14]?: number;
};
export class BookingLimitsCount_2024_06_14 {
export class BaseBookingLimitsCount_2024_06_14 {
@IsOptional()
@IsInt()
@Min(1)
@@ -44,8 +46,13 @@ export class BookingLimitsCount_2024_06_14 {
example: 4,
})
year?: number;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export type BookingLimitsCount_2024_06_14 = BaseBookingLimitsCount_2024_06_14 | Disabled_2024_06_14;
// Custom validator to handle the union type
@ValidatorConstraint({ name: "BookingLimitsCountValidator", async: false })
class BookingLimitsCountValidator implements ValidatorConstraintInterface {
@@ -55,6 +62,9 @@ class BookingLimitsCountValidator implements ValidatorConstraintInterface {
} = {};
validate(value: BookingLimitsCount_2024_06_14) {
if (!value) return false;
if ("disabled" in value) {
return true;
}
const { day, week, month, year } = value;
@@ -84,7 +94,10 @@ class BookingLimitsCountValidator implements ValidatorConstraintInterface {
defaultMessage() {
const { invalidLimit, comparedLimit } = this.errorDetails;
return `Invalid booking limits: The number of bookings for ${invalidLimit} cannot exceed the number of bookings for ${comparedLimit}.`;
if (invalidLimit && comparedLimit) {
return `Invalid booking limits: The number of bookings for ${invalidLimit} cannot exceed the number of bookings for ${comparedLimit}.`;
}
return `Invalid booking limits count structure`;
}
}
@@ -1,8 +1,10 @@
import { ApiProperty } from "@nestjs/swagger";
import type { ValidatorConstraintInterface, ValidationOptions } from "class-validator";
import { IsInt, IsOptional, Min, ValidatorConstraint, registerDecorator } from "class-validator";
import { IsBoolean, IsInt, IsOptional, Min, ValidatorConstraint, registerDecorator } from "class-validator";
export class BookingLimitsDuration_2024_06_14 {
import type { Disabled_2024_06_14 } from "./disabled.input";
export class BaseBookingLimitsDuration_2024_06_14 {
@IsOptional()
@IsInt()
@Min(15)
@@ -38,8 +40,13 @@ export class BookingLimitsDuration_2024_06_14 {
example: 240,
})
year?: number;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export type BookingLimitsDuration_2024_06_14 = BaseBookingLimitsDuration_2024_06_14 | Disabled_2024_06_14;
@ValidatorConstraint({ name: "BookingLimitsDurationValidator", async: false })
class BookingLimitsDurationValidator implements ValidatorConstraintInterface {
private errorDetails: {
@@ -48,6 +55,9 @@ class BookingLimitsDurationValidator implements ValidatorConstraintInterface {
} = {};
validate(value: BookingLimitsDuration_2024_06_14) {
if (!value) return false;
if ("disabled" in value) {
return true;
}
const { day, week, month, year } = value;
@@ -77,7 +87,10 @@ class BookingLimitsDurationValidator implements ValidatorConstraintInterface {
defaultMessage() {
const { invalidLimit, comparedLimit } = this.errorDetails;
return `Invalid booking durations: The duration of bookings for ${invalidLimit} cannot exceed the duration of bookings for ${comparedLimit}.`;
if (invalidLimit && comparedLimit) {
return `Invalid booking durations: The duration of bookings for ${invalidLimit} cannot exceed the duration of bookings for ${comparedLimit}.`;
}
return `Invalid booking durations structure`;
}
}
@@ -1,4 +1,3 @@
import { BadRequestException } from "@nestjs/common";
import { ApiProperty } from "@nestjs/swagger";
import type { ValidatorConstraintInterface, ValidationOptions } from "class-validator";
import {
@@ -16,8 +15,10 @@ import {
import { BookingWindowPeriodInputTypeEnum_2024_06_14 } from "@calcom/platform-enums";
import type { Disabled_2024_06_14 } from "./disabled.input";
export type BookingWindowPeriodInputType_2024_06_14 = "businessDays" | "calendarDays" | "range";
export type BookingWindowPeriodOutputType_2024_06_14 = "RANGE" | "ROLLING_WINDOW" | "ROLLING";
export type BookingWindowPeriodOutputType_2024_06_14 = "RANGE" | "ROLLING_WINDOW" | "ROLLING" | "UNLIMITED";
export type TransformFutureBookingsLimitSchema_2024_06_14 = {
periodType: BookingWindowPeriodOutputType_2024_06_14;
@@ -52,6 +53,10 @@ export class BusinessDaysWindow_2024_06_14 extends BookingWindowBase {
"If true, the window will be rolling aka from the moment that someone is trying to book this event. Otherwise it will be specified amount of days from the current date.",
})
rolling?: boolean;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export class CalendarDaysWindow_2024_06_14 extends BookingWindowBase {
@@ -68,6 +73,10 @@ export class CalendarDaysWindow_2024_06_14 extends BookingWindowBase {
"If true, the window will be rolling aka from the moment that someone is trying to book this event. Otherwise it will be specified amount of days from the current date.",
})
rolling?: boolean;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export class RangeWindow_2024_06_14 extends BookingWindowBase {
@@ -81,39 +90,48 @@ export class RangeWindow_2024_06_14 extends BookingWindowBase {
description: "Date range for when this event can be booked.",
})
value!: string[];
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export type BookingWindow_2024_06_14 =
| BusinessDaysWindow_2024_06_14
| CalendarDaysWindow_2024_06_14
| RangeWindow_2024_06_14;
| RangeWindow_2024_06_14
| Disabled_2024_06_14;
// Custom validator to handle the union type
@ValidatorConstraint({ name: "bookingWindowValidator", async: false })
class BookingWindowValidator implements ValidatorConstraintInterface {
validate(value: BookingWindow_2024_06_14) {
if (!value || !value.type) {
throw new BadRequestException(`'BookingWindow' must have a type`);
if ("disabled" in value && value.disabled === true) {
return true;
}
switch (value.type) {
case BookingWindowPeriodInputTypeEnum_2024_06_14.businessDays:
case BookingWindowPeriodInputTypeEnum_2024_06_14.calendarDays:
return (
typeof value.value === "number" &&
(typeof (value as BusinessDaysWindow_2024_06_14 | CalendarDaysWindow_2024_06_14).rolling ===
"undefined" ||
typeof (value as BusinessDaysWindow_2024_06_14 | CalendarDaysWindow_2024_06_14).rolling ===
"boolean")
);
case BookingWindowPeriodInputTypeEnum_2024_06_14.range:
return (
Array.isArray(value.value) &&
value.value.every((date: any) => typeof date === "string" && !isNaN(Date.parse(date)))
);
default:
return false;
if ("type" in value) {
switch (value.type) {
case BookingWindowPeriodInputTypeEnum_2024_06_14.businessDays:
case BookingWindowPeriodInputTypeEnum_2024_06_14.calendarDays:
return (
typeof value.value === "number" &&
(typeof (value as BusinessDaysWindow_2024_06_14 | CalendarDaysWindow_2024_06_14).rolling ===
"undefined" ||
typeof (value as BusinessDaysWindow_2024_06_14 | CalendarDaysWindow_2024_06_14).rolling ===
"boolean")
);
case BookingWindowPeriodInputTypeEnum_2024_06_14.range:
return (
Array.isArray(value.value) &&
value.value.every((date: any) => typeof date === "string" && !isNaN(Date.parse(date)))
);
default:
return false;
}
}
return false;
}
defaultMessage() {
@@ -0,0 +1,108 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsEnum, IsOptional, IsInt, ValidateNested, IsBoolean } from "class-validator";
import type { ValidatorConstraintInterface, ValidationOptions } from "class-validator";
import { ValidatorConstraint, registerDecorator } from "class-validator";
import { ConfirmationPolicyEnum, NoticeThresholdUnitEnum } from "@calcom/platform-enums";
import type { Disabled_2024_06_14 } from "./disabled.input";
// Class representing the notice threshold
export class NoticeThreshold_2024_06_14 {
@IsEnum(NoticeThresholdUnitEnum)
@ApiProperty({
description: "The unit of time for the notice threshold (e.g., minutes, hours)",
example: NoticeThresholdUnitEnum.MINUTES,
})
unit!: NoticeThresholdUnitEnum;
@IsInt()
@ApiProperty({
description: "The time value for the notice threshold",
example: 30,
})
count!: number;
}
// Class representing the confirmation requirements
export class BaseConfirmationPolicy_2024_06_14 {
@IsEnum(ConfirmationPolicyEnum)
@ApiProperty({
description: "The policy that determines when confirmation is required",
example: ConfirmationPolicyEnum.ALWAYS,
})
type!: ConfirmationPolicyEnum;
@IsOptional()
@ValidateNested()
@Type(() => NoticeThreshold_2024_06_14)
@ApiPropertyOptional({
description: "The notice threshold required before confirmation is needed. Required when type is 'time'.",
type: NoticeThreshold_2024_06_14,
})
noticeThreshold?: NoticeThreshold_2024_06_14;
@IsBoolean()
blockUnconfirmedBookingsInBooker!: boolean;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export type ConfirmationPolicy_2024_06_14 = BaseConfirmationPolicy_2024_06_14 | Disabled_2024_06_14;
// Validator for confirmation settings
@ValidatorConstraint({ name: "ConfirmationPolicyValidator", async: false })
export class ConfirmationPolicyValidator implements ValidatorConstraintInterface {
validate(value: ConfirmationPolicy_2024_06_14): boolean {
if (value.disabled) {
return true;
}
const { type, noticeThreshold } = value;
if (!type) return false;
if (type === ConfirmationPolicyEnum.ALWAYS) {
return true;
}
if (type === ConfirmationPolicyEnum.TIME) {
return !!(
noticeThreshold &&
typeof noticeThreshold.count === "number" &&
typeof noticeThreshold.unit === "string"
);
}
return false;
}
defaultMessage(): string {
return `Invalid requiresConfirmation structure. Use "type": "always" or provide a valid time and unit in "noticeThreshold" for "type": "time".`;
}
}
// Custom decorator for confirmation validation
export function ValidateConfirmationPolicy(validationOptions?: ValidationOptions) {
return function (object: any, propertyName: string) {
registerDecorator({
name: "ValidateConfirmationPolicy",
target: object.constructor,
propertyName,
options: validationOptions,
validator: ConfirmationPolicyValidator,
});
};
}
export type NoticeThresholdTransformedSchema = {
unit: NoticeThresholdUnitEnum;
time: number;
};
export type ConfirmationPolicyTransformedSchema = {
requiresConfirmation: boolean;
requiresConfirmationThreshold?: NoticeThresholdTransformedSchema;
requiresConfirmationWillBlockSlot: boolean;
};
@@ -1,5 +1,5 @@
import { ApiProperty as DocsProperty, getSchemaPath, ApiExtraModels } from "@nestjs/swagger";
import { Type, Transform } from "class-transformer";
import { Type, Transform, Expose } from "class-transformer";
import {
IsString,
IsInt,
@@ -13,6 +13,7 @@ import {
import { SchedulingType } from "@calcom/platform-enums";
import { BookerLayouts_2024_06_14 } from "./booker-layouts.input";
import {
AddressFieldInput_2024_06_14,
BooleanFieldInput_2024_06_14,
@@ -28,11 +29,10 @@ import {
} from "./booking-fields.input";
import type { InputBookingField_2024_06_14 } from "./booking-fields.input";
import { ValidateInputBookingFields_2024_06_14 } from "./booking-fields.input";
import { BookingLimitsCount_2024_06_14, ValidateBookingLimistsCount } from "./booking-limits-count.input";
import {
BookingLimitsDuration_2024_06_14,
ValidateBookingLimistsDuration,
} from "./booking-limits-duration.input";
import type { BookingLimitsCount_2024_06_14 } from "./booking-limits-count.input";
import { ValidateBookingLimistsCount } from "./booking-limits-count.input";
import type { BookingLimitsDuration_2024_06_14 } from "./booking-limits-duration.input";
import { ValidateBookingLimistsDuration } from "./booking-limits-duration.input";
import type { BookingWindow_2024_06_14 } from "./booking-window.input";
import {
BusinessDaysWindow_2024_06_14,
@@ -40,6 +40,11 @@ import {
RangeWindow_2024_06_14,
ValidateBookingWindow,
} from "./booking-window.input";
import type { ConfirmationPolicy_2024_06_14 } from "./confirmation-policy.input";
import { ValidateConfirmationPolicy } from "./confirmation-policy.input";
import { DestinationCalendar_2024_06_14 } from "./destination-calendar.input";
import { Disabled_2024_06_14 } from "./disabled.input";
import { EventTypeColor_2024_06_14 } from "./event-type-color.input";
import {
AddressLocation_2024_06_14,
IntegrationLocation_2024_06_14,
@@ -49,6 +54,7 @@ import {
} from "./locations.input";
import type { Location_2024_06_14 } from "./locations.input";
import { Recurrence_2024_06_14 } from "./recurrence.input";
import { Seats_2024_06_14 } from "./seats.input";
export const CREATE_EVENT_LENGTH_EXAMPLE = 60;
export const CREATE_EVENT_TITLE_EXAMPLE = "Learn the secrets of masterchief!";
@@ -177,7 +183,6 @@ export class CreateEventTypeInput_2024_06_14 {
scheduleId?: number;
@IsOptional()
@Type(() => BookingLimitsCount_2024_06_14)
@ValidateBookingLimistsCount()
@DocsProperty({ description: "Limit how many times this event can be booked" })
bookingLimitsCount?: BookingLimitsCount_2024_06_14;
@@ -191,7 +196,6 @@ export class CreateEventTypeInput_2024_06_14 {
onlyShowFirstAvailableSlot?: boolean;
@IsOptional()
@Type(() => BookingLimitsDuration_2024_06_14)
@ValidateBookingLimistsDuration()
@DocsProperty({ description: "Limit total amount of time that this event can be booked" })
bookingLimitsDuration?: BookingLimitsDuration_2024_06_14;
@@ -217,12 +221,75 @@ export class CreateEventTypeInput_2024_06_14 {
offsetStart?: number;
@IsOptional()
@Type(() => BookerLayouts_2024_06_14)
bookerLayouts?: BookerLayouts_2024_06_14;
@IsOptional()
@ValidateConfirmationPolicy()
confirmationPolicy?: ConfirmationPolicy_2024_06_14;
@ValidateNested()
@Type(() => Recurrence_2024_06_14)
@DocsProperty({
description: "Create a recurring event that can be booked once but will occur multiple times",
@Transform(({ value }) => {
if (value && typeof value === "object") {
if ("interval" in value) {
return Object.assign(new Recurrence_2024_06_14(), value);
} else if ("disabled" in value) {
return Object.assign(new Disabled_2024_06_14(), value);
}
}
return value;
})
recurrence?: Recurrence_2024_06_14;
@ValidateNested()
recurrence?: Recurrence_2024_06_14 | Disabled_2024_06_14;
@IsOptional()
@IsBoolean()
requiresBookerEmailVerification?: boolean;
@IsOptional()
@IsBoolean()
hideCalendarNotes?: boolean;
@IsOptional()
@IsBoolean()
lockTimeZoneToggleOnBookingPage?: boolean;
@IsOptional()
@Type(() => EventTypeColor_2024_06_14)
color?: EventTypeColor_2024_06_14;
@IsOptional()
@Transform(({ value }) => {
if (value && typeof value === "object") {
if ("seatsPerTimeSlot" in value) {
return Object.assign(new Seats_2024_06_14(), value);
} else if ("disabled" in value) {
return Object.assign(new Disabled_2024_06_14(), value);
}
}
return value;
})
@ValidateNested()
seats?: Seats_2024_06_14 | Disabled_2024_06_14;
@IsOptional()
@IsString()
@DocsProperty({
description: `Customizable event name with valid variables:
{Event type title}, {Organiser}, {Scheduler}, {Location}, {Organiser first name},
{Scheduler first name}, {Scheduler last name}, {Event duration}, {LOCATION},
{HOST/ATTENDEE}, {HOST}, {ATTENDEE}, {USER}`,
example: "{Event type title} between {Organiser} and {Scheduler}",
})
customName?: string;
@IsOptional()
@Type(() => DestinationCalendar_2024_06_14)
destinationCalendar?: DestinationCalendar_2024_06_14;
@IsOptional()
@IsBoolean()
useDestinationCalendarEmail?: boolean;
}
export enum HostPriority {
@@ -233,11 +300,13 @@ export enum HostPriority {
highest = "highest",
}
export class Host {
@Expose()
@IsInt()
@DocsProperty({ description: "Which user is the host of this event" })
userId!: number;
@IsOptional()
@Expose()
@IsBoolean()
@DocsProperty({
description:
@@ -246,6 +315,7 @@ export class Host {
mandatory?: boolean = false;
@IsEnum(HostPriority)
@Expose()
@IsOptional()
@DocsProperty({ enum: HostPriority })
priority?: keyof typeof HostPriority = "medium";
@@ -0,0 +1,18 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsString } from "class-validator";
export class DestinationCalendar_2024_06_14 {
@ApiProperty({
description:
"The integration type of the destination calendar. Refer to the /api/v2/calendars endpoint to retrieve the integration type of your connected calendars.",
})
@IsString()
integration!: string;
@ApiProperty({
description:
"The external ID of the destination calendar. Refer to the /api/v2/calendars endpoint to retrieve the external IDs of your connected calendars.",
})
@IsString()
externalId!: string;
}
@@ -0,0 +1,13 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsOptional } from "class-validator";
export class Disabled_2024_06_14 {
@IsOptional()
@IsBoolean()
@ApiProperty({
description: "Indicates if the option is disabled",
example: true,
default: false,
})
disabled!: true;
}
@@ -0,0 +1,26 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsHexColor, IsString } from "class-validator";
// Class representing the event type colors
export class EventTypeColor_2024_06_14 {
@IsHexColor()
@IsString()
@ApiProperty({
description: "Color used for event types in light theme",
example: "#292929",
})
lightThemeHex!: string;
@IsHexColor()
@IsString()
@ApiProperty({
description: "Color used for event types in dark theme",
example: "#fafafa",
})
darkThemeHex!: string;
}
export type EventTypeColorsTransformedSchema = {
darkEventTypeColor: string;
lightEventTypeColor: string;
};
@@ -7,3 +7,9 @@ export * from "./booking-fields.input";
export * from "./recurrence.input";
export * from "./update-event-type.input";
export * from "./get-event-types-query.input";
export * from "./booker-layouts.input";
export * from "./confirmation-policy.input";
export * from "./event-type-color.input";
export * from "./seats.input";
export * from "./destination-calendar.input";
export * from "./disabled.input";
@@ -1,5 +1,5 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsInt, IsEnum } from "class-validator";
import { IsInt, IsEnum, IsOptional, IsBoolean } from "class-validator";
import { FrequencyInput } from "@calcom/platform-enums";
@@ -21,4 +21,8 @@ export class Recurrence_2024_06_14 {
@IsEnum(FrequencyInput)
@ApiProperty({ enum: FrequencyInput })
frequency!: FrequencyInput;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
@@ -0,0 +1,41 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsInt, IsOptional, Min } from "class-validator";
// Class representing the seat options
export class Seats_2024_06_14 {
@IsInt()
@Min(1)
@ApiProperty({
description: "Number of seats available per time slot",
example: 4,
})
seatsPerTimeSlot!: number;
@IsBoolean()
@ApiProperty({
description: "Show attendee information to other guests",
example: true,
})
showAttendeeInfo!: boolean;
@IsBoolean()
@ApiProperty({
description: "Display the count of available seats",
example: true,
})
showAvailabilityCount!: boolean;
@IsOptional()
@IsBoolean()
disabled?: boolean = false;
}
export type SeatOptionsTransformedSchema = {
seatsPerTimeSlot: number;
seatsShowAttendees: boolean;
seatsShowAvailabilityCount: boolean;
};
export type SeatOptionsDisabledSchema = {
seatsPerTimeSlot: null;
};
@@ -1,7 +1,8 @@
import { ApiProperty as DocsProperty, getSchemaPath, ApiExtraModels } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { Type, Transform } from "class-transformer";
import { IsString, IsInt, IsBoolean, IsOptional, Min, ValidateNested, IsArray } from "class-validator";
import { BookerLayouts_2024_06_14 } from "./booker-layouts.input";
import type { InputBookingField_2024_06_14 } from "./booking-fields.input";
import {
AddressFieldInput_2024_06_14,
@@ -17,11 +18,10 @@ import {
TextFieldInput_2024_06_14,
ValidateInputBookingFields_2024_06_14,
} from "./booking-fields.input";
import { BookingLimitsCount_2024_06_14, ValidateBookingLimistsCount } from "./booking-limits-count.input";
import {
BookingLimitsDuration_2024_06_14,
ValidateBookingLimistsDuration,
} from "./booking-limits-duration.input";
import type { BookingLimitsCount_2024_06_14 } from "./booking-limits-count.input";
import { ValidateBookingLimistsCount } from "./booking-limits-count.input";
import type { BookingLimitsDuration_2024_06_14 } from "./booking-limits-duration.input";
import { ValidateBookingLimistsDuration } from "./booking-limits-duration.input";
import {
BusinessDaysWindow_2024_06_14,
CalendarDaysWindow_2024_06_14,
@@ -29,6 +29,8 @@ import {
ValidateBookingWindow,
type BookingWindow_2024_06_14,
} from "./booking-window.input";
import type { ConfirmationPolicy_2024_06_14 } from "./confirmation-policy.input";
import { ValidateConfirmationPolicy } from "./confirmation-policy.input";
import {
CREATE_EVENT_DESCRIPTION_EXAMPLE,
CREATE_EVENT_LENGTH_EXAMPLE,
@@ -36,6 +38,9 @@ import {
CREATE_EVENT_TITLE_EXAMPLE,
Host,
} from "./create-event-type.input";
import { DestinationCalendar_2024_06_14 } from "./destination-calendar.input";
import { Disabled_2024_06_14 } from "./disabled.input";
import { EventTypeColor_2024_06_14 } from "./event-type-color.input";
import {
AddressLocation_2024_06_14,
IntegrationLocation_2024_06_14,
@@ -45,6 +50,7 @@ import {
} from "./locations.input";
import type { Location_2024_06_14 } from "./locations.input";
import { Recurrence_2024_06_14 } from "./recurrence.input";
import { Seats_2024_06_14 } from "./seats.input";
@ApiExtraModels(
AddressLocation_2024_06_14,
@@ -78,8 +84,8 @@ export class UpdateEventTypeInput_2024_06_14 {
@DocsProperty({ example: CREATE_EVENT_TITLE_EXAMPLE })
title?: string;
@IsString()
@IsOptional()
@IsString()
@DocsProperty({ example: CREATE_EVENT_SLUG_EXAMPLE })
slug?: string;
@@ -170,7 +176,6 @@ export class UpdateEventTypeInput_2024_06_14 {
scheduleId?: number;
@IsOptional()
@Type(() => BookingLimitsCount_2024_06_14)
@ValidateBookingLimistsCount()
@DocsProperty({ description: "Limit how many times this event can be booked" })
bookingLimitsCount?: BookingLimitsCount_2024_06_14;
@@ -184,7 +189,6 @@ export class UpdateEventTypeInput_2024_06_14 {
onlyShowFirstAvailableSlot?: boolean;
@IsOptional()
@Type(() => BookingLimitsDuration_2024_06_14)
@ValidateBookingLimistsDuration()
@DocsProperty({ description: "Limit total amount of time that this event can be booked" })
bookingLimitsDuration?: BookingLimitsDuration_2024_06_14;
@@ -210,12 +214,74 @@ export class UpdateEventTypeInput_2024_06_14 {
offsetStart?: number;
@IsOptional()
@ValidateNested()
@Type(() => Recurrence_2024_06_14)
@DocsProperty({
description: "Create a recurring event that can be booked once but will occur multiple times",
@Type(() => BookerLayouts_2024_06_14)
bookerLayouts?: BookerLayouts_2024_06_14;
@IsOptional()
@ValidateConfirmationPolicy()
confirmationPolicy?: ConfirmationPolicy_2024_06_14;
@Transform(({ value }) => {
if (value && typeof value === "object") {
if ("interval" in value) {
return Object.assign(new Recurrence_2024_06_14(), value);
} else if ("disabled" in value) {
return Object.assign(new Disabled_2024_06_14(), value);
}
}
return value;
})
recurrence?: Recurrence_2024_06_14;
@ValidateNested()
recurrence?: Recurrence_2024_06_14 | Disabled_2024_06_14;
@IsOptional()
@IsBoolean()
requiresBookerEmailVerification?: boolean;
@IsOptional()
@IsBoolean()
hideCalendarNotes?: boolean;
@IsOptional()
@IsBoolean()
lockTimeZoneToggleOnBookingPage?: boolean;
@IsOptional()
@Type(() => EventTypeColor_2024_06_14)
color?: EventTypeColor_2024_06_14;
@IsOptional()
@Transform(({ value }) => {
if (value && typeof value === "object") {
if ("seatsPerTimeSlot" in value) {
return Object.assign(new Seats_2024_06_14(), value);
} else if ("disabled" in value) {
return Object.assign(new Disabled_2024_06_14(), value);
}
}
return value;
})
@ValidateNested()
seats?: Seats_2024_06_14 | Disabled_2024_06_14;
@IsOptional()
@IsString()
@DocsProperty({
description: `Customizable event name with valid variables:
{Event type title}, {Organiser}, {Scheduler}, {Location}, {Organiser first name},
{Scheduler first name}, {Scheduler last name}, {Event duration}, {LOCATION},
{HOST/ATTENDEE}, {HOST}, {ATTENDEE}, {USER}`,
example: "{Event type title} between {Organiser} and {Scheduler}",
})
customName?: string;
@IsOptional()
@Type(() => DestinationCalendar_2024_06_14)
destinationCalendar?: DestinationCalendar_2024_06_14;
@IsOptional()
@IsBoolean()
useDestinationCalendarEmail?: boolean;
}
@ApiExtraModels(
@@ -246,8 +312,8 @@ export class UpdateTeamEventTypeInput_2024_06_14 extends UpdateEventTypeInput_20
@DocsProperty()
hosts?: Host[];
@IsBoolean()
@IsOptional()
@IsBoolean()
@DocsProperty()
@DocsProperty({
description: "If true, all current and future team members will be assigned to this event type",
@@ -1,4 +1,4 @@
import { ApiProperty as DocsProperty, getSchemaPath, ApiExtraModels } from "@nestjs/swagger";
import { ApiProperty as DocsProperty, ApiExtraModels, getSchemaPath } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsArray,
@@ -11,16 +11,25 @@ import {
ValidateNested,
} from "class-validator";
import type { Location_2024_06_14, BookingWindow_2024_06_14 } from "../inputs";
import {
Host as TeamEventTypeHostInput,
import type {
Location_2024_06_14,
BookingWindow_2024_06_14,
BookingLimitsDuration_2024_06_14,
} from "../inputs";
import {
EventTypeColor_2024_06_14,
Seats_2024_06_14,
Host as TeamEventTypeHostInput,
BaseBookingLimitsDuration_2024_06_14,
BusinessDaysWindow_2024_06_14,
CalendarDaysWindow_2024_06_14,
RangeWindow_2024_06_14,
} from "../inputs";
import { Recurrence_2024_06_14 } from "../inputs";
import { BookingLimitsCount_2024_06_14 } from "../inputs/booking-limits-count.input";
import { BookerLayouts_2024_06_14 } from "../inputs/booker-layouts.input";
import type { BookingLimitsCount_2024_06_14 } from "../inputs/booking-limits-count.input";
import type { ConfirmationPolicy_2024_06_14 } from "../inputs/confirmation-policy.input";
import { DestinationCalendar_2024_06_14 } from "../inputs/destination-calendar.input";
import {
AddressLocation_2024_06_14,
IntegrationLocation_2024_06_14,
@@ -81,6 +90,7 @@ class User_2024_06_14 {
@IsString()
darkBrandColor!: string | null;
@Type(() => Object)
metadata!: Record<string, unknown>;
}
@@ -107,7 +117,7 @@ class User_2024_06_14 {
SelectFieldOutput_2024_06_14,
TextAreaFieldOutput_2024_06_14,
TextFieldOutput_2024_06_14,
BookingLimitsDuration_2024_06_14,
BaseBookingLimitsDuration_2024_06_14,
BusinessDaysWindow_2024_06_14,
CalendarDaysWindow_2024_06_14,
RangeWindow_2024_06_14
@@ -132,7 +142,7 @@ class BaseEventTypeOutput_2024_06_14 {
@IsString()
@DocsProperty({
example: "Discover the culinary wonders of the Argentina by making the best flan ever!",
example: "Discover the culinary wonders of Argentina by making the best flan ever!",
})
description!: string;
@@ -150,6 +160,7 @@ class BaseEventTypeOutput_2024_06_14 {
locations!: Location_2024_06_14[];
@ValidateOutputBookingFields_2024_06_14()
@DocsProperty()
@DocsProperty({
oneOf: [
{ $ref: getSchemaPath(NameDefaultFieldOutput_2024_06_14) },
@@ -209,10 +220,6 @@ class BaseEventTypeOutput_2024_06_14 {
@DocsProperty()
metadata!: Record<string, unknown>;
@IsBoolean()
@DocsProperty()
requiresConfirmation!: boolean;
@IsInt()
@DocsProperty()
price!: number;
@@ -227,7 +234,8 @@ class BaseEventTypeOutput_2024_06_14 {
@IsInt()
@DocsProperty()
seatsPerTimeSlot!: number | null;
@IsOptional()
seatsPerTimeSlot?: number | null;
@IsBoolean()
@DocsProperty()
@@ -239,7 +247,12 @@ class BaseEventTypeOutput_2024_06_14 {
@IsBoolean()
@DocsProperty()
seatsShowAvailabilityCount!: boolean | null;
isInstantEvent!: boolean;
@IsOptional()
@IsBoolean()
@DocsProperty()
seatsShowAvailabilityCount?: boolean | null;
@IsInt()
@DocsProperty()
@@ -247,7 +260,6 @@ class BaseEventTypeOutput_2024_06_14 {
@IsOptional()
@DocsProperty()
@Type(() => BookingLimitsCount_2024_06_14)
bookingLimitsCount?: BookingLimitsCount_2024_06_14;
@IsOptional()
@@ -256,7 +268,6 @@ class BaseEventTypeOutput_2024_06_14 {
onlyShowFirstAvailableSlot?: boolean;
@IsOptional()
@Type(() => BookingLimitsDuration_2024_06_14)
@DocsProperty()
bookingLimitsDuration?: BookingLimitsDuration_2024_06_14;
@@ -273,11 +284,55 @@ class BaseEventTypeOutput_2024_06_14 {
@Type(() => Object)
bookingWindow?: BookingWindow_2024_06_14;
@IsOptional()
@Type(() => BookerLayouts_2024_06_14)
@DocsProperty()
bookerLayouts?: BookerLayouts_2024_06_14;
@IsOptional()
@DocsProperty()
confirmationPolicy?: ConfirmationPolicy_2024_06_14;
@IsOptional()
@IsBoolean()
@DocsProperty()
requiresBookerEmailVerification?: boolean;
@IsOptional()
@IsBoolean()
@DocsProperty()
hideCalendarNotes?: boolean;
@IsOptional()
@Type(() => EventTypeColor_2024_06_14)
@DocsProperty()
color?: EventTypeColor_2024_06_14;
@IsOptional()
@Type(() => Seats_2024_06_14)
@DocsProperty()
seats?: Seats_2024_06_14;
@IsOptional()
@IsInt()
@Min(1)
@DocsProperty()
offsetStart?: number;
@IsOptional()
@IsString()
@DocsProperty()
customName?: string;
@IsOptional()
@Type(() => DestinationCalendar_2024_06_14)
@DocsProperty()
destinationCalendar?: DestinationCalendar_2024_06_14;
@IsOptional()
@IsBoolean()
@DocsProperty()
useDestinationCalendarEmail?: boolean;
}
export class TeamEventTypeResponseHost extends TeamEventTypeHostInput {
@@ -298,10 +353,6 @@ export class EventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_14 {
}
export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_14 {
@IsEnum(SchedulingTypeEnum)
@DocsProperty({ enum: SchedulingTypeEnum })
schedulingType!: EventTypesOutputSchedulingType | null;
@IsInt()
@IsOptional()
@DocsProperty()
@@ -316,7 +367,7 @@ export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_
@IsOptional()
@DocsProperty({
description:
"For managed event types parent event type is the event type that this event type is based on",
"For managed event types, parent event type is the event type that this event type is based on",
})
parentEventTypeId?: number | null;
@@ -330,4 +381,8 @@ export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_
@IsOptional()
@DocsProperty()
assignAllTeamMembers?: boolean;
@IsEnum(SchedulingTypeEnum)
@DocsProperty({ enum: SchedulingTypeEnum })
schedulingType!: EventTypesOutputSchedulingType | null;
}
@@ -0,0 +1,59 @@
import type { z } from "zod";
import type {
transformEventColorsApiToInternal,
transformFutureBookingLimitsApiToInternal,
transformIntervalLimitsApiToInternal,
transformRecurrenceApiToInternal,
transformSeatsApiToInternal,
transformBookingFieldsApiToInternal,
TransformedLocationsSchema,
} from "@calcom/lib/event-types/transformers";
import type { CreateEventTypeInput_2024_06_14, ConfirmationPolicyTransformedSchema } from "../inputs";
export type InputEventTransformed_2024_06_14 = Omit<
CreateEventTypeInput_2024_06_14,
| "lengthInMinutes"
| "locations"
| "bookingFields"
| "bookingLimitsCount"
| "bookingLimitsDuration"
| "bookingWindow"
| "bookerLayouts"
| "confirmationPolicy"
| "recurrence"
| "color"
| "seats"
| "customName"
| "useDestinationCalendarEmail"
> & {
length: number;
slug: string;
eventName?: string;
bookingLimits?: ReturnType<typeof transformIntervalLimitsApiToInternal>;
locations?: z.infer<typeof TransformedLocationsSchema>;
bookingFields?: ReturnType<typeof transformBookingFieldsApiToInternal>;
durationLimits?: ReturnType<typeof transformIntervalLimitsApiToInternal>;
recurringEvent?: ReturnType<typeof transformRecurrenceApiToInternal>;
eventTypeColor?: ReturnType<typeof transformEventColorsApiToInternal>;
useEventTypeDestinationCalendarEmail?: boolean;
} & Partial<
Pick<ConfirmationPolicyTransformedSchema, "requiresConfirmation" | "requiresConfirmationWillBlockSlot">
> &
Partial<ReturnType<typeof transformSeatsApiToInternal>> &
Partial<ReturnType<typeof transformFutureBookingLimitsApiToInternal>>;
export type InputTeamEventTransformed_2024_06_14 = InputEventTransformed_2024_06_14 & {
hosts: {
userId: number;
isFixed: boolean;
priority: number;
}[];
children: {
id: number;
name: string;
email: string;
eventTypeSlugs: string[];
}[];
};
@@ -0,0 +1 @@
export * from "./event-type.tranformed";