feat: add missing event type fields for advanced settings in api v2 (#25739)

* feat: api v2 add missing event type fields for advanced settings

Add 9 event type fields to API v2 that were available in tRPC but missing from the platform API:

- disableCancelling: disable cancelling for guests/organizer
- disableRescheduling: disable rescheduling for guests/organizer
- canSendCalVideoTranscriptionEmails: send Cal Video transcription emails
- autoTranslateInstantMeetingTitleEnabled: auto-translate instant meeting titles
- interfaceLanguage: preferred booking interface language
- allowReschedulingPastBookings: allow rescheduling past events
- allowReschedulingCancelledBookings: allow booking via reschedule link
- customReplyToEmail: custom reply-to email for confirmations
- showOptimizedSlots: optimize time slot arrangement

Updated output/input schemas, transformation services, and E2E tests.

* fix(api-v2): add proper OpenAPI types for nullable event type fields

Add explicit type and nullable properties to @ApiPropertyOptional decorators
for fields with `boolean | null` or `string | null` types. Without these,
Swagger was generating incorrect "type": "object" instead of the correct types.

Fixed fields:
- disableCancelling: type: Boolean, nullable: true
- disableRescheduling: type: Boolean, nullable: true
- interfaceLanguage: type: String, nullable: true
- allowReschedulingCancelledBookings: type: Boolean, nullable: true
- customReplyToEmail: type: String, nullable: true
- showOptimizedSlots: type: Boolean, nullable: true

* refactor: customReplyToEmail was intentionally excluded from this PR. The web UI
restricts this field to only allow the user's own verified emails via a
dropdown, but implementing the same validation in the API requires additional
business logic. This will be addressed in a separate PR with proper email
ownership validation.

* feat(api-v2): add validation for interfaceLanguage field

Add @IsIn validation to interfaceLanguage field to only accept supported
locales. This ensures API v2 matches the web UI behavior where users can
only select from a predefined dropdown of supported languages.

Changes:
- Add SUPPORTED_LOCALES constant to @calcom/platform-constants
- Add @IsIn([...SUPPORTED_LOCALES]) validation to create/update DTOs
- Add E2E tests for invalid locale rejection (400 error)
- Add cross-reference comments in i18n.json and api.ts to keep in sync

* docs(api): add default values to event type input field documentation

Added default value documentation to @DocsPropertyOptional decorators
for the new event type fields in API v2 (2024_06_14):

- disableCancelling: false
- disableRescheduling: false
- canSendCalVideoTranscriptionEmails: true
- autoTranslateInstantMeetingTitleEnabled: false
- allowReschedulingPastBookings: false
- allowReschedulingCancelledBookings: false
- showOptimizedSlots: false

This improves API documentation by clearly communicating default
values to API consumers in the OpenAPI spec.

* feat(api-v2): refactor event type settings to object types for future extensibility

- Convert disableRescheduling from boolean to object with disabled and minutesBefore properties
- Convert disableCancelling from boolean to object with disabled property
- Move canSendCalVideoTranscriptionEmails into CalVideoSettings as sendTranscriptionEmails
- Remove autoTranslateInstantMeetingTitleEnabled (Enterprise-only feature)
- Add DisableRescheduling_2024_06_14 and DisableCancelling_2024_06_14 input/output types
- Add transformation methods for new object types in input and output services
- Update E2E tests for new API contract

BREAKING CHANGE: disableRescheduling and disableCancelling now accept objects instead of booleans

* fix(api-v2): prevent clearing calVideoSettings when only sendTranscriptionEmails is provided

Only include calVideoSettings in transformed output if it has properties,
avoiding unintentional reset of existing settings during updates.
This commit is contained in:
Dhairyashil Shinde authored and GitHub committed 2026-01-07 16:03:01 +02:00
1 parent 4571215794
commit dcf10935de
17 files changed
+1046 -5

No files matched your search

@@ -432,6 +432,29 @@ describe("Event types Endpoints", () => {
.expect(400);
});
it("should return an error when creating an event type with invalid interfaceLanguage", async () => {
const body: CreateEventTypeInput_2024_06_14 = {
title: "Coding class invalid locale",
slug: "coding-class-invalid-locale",
description: "Let's learn how to code like a pro.",
lengthInMinutes: 60,
locations: [
{
type: "integration",
integration: "cal-video",
},
],
interfaceLanguage: "invalid-locale-xyz",
};
return request(app.getHttpServer())
.post("/api/v2/event-types")
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.set("Authorization", `Bearer ${apiKeyString}`)
.send(body)
.expect(400);
});
it("should create an event type", async () => {
const nameBookingField: NameDefaultFieldInput_2024_06_14 = {
type: "name",
@@ -532,6 +555,13 @@ describe("Event types Endpoints", () => {
},
customName: `{Event type title} between {Organiser} and {Scheduler}`,
bookingRequiresAuthentication: true,
disableCancelling: { disabled: true },
disableRescheduling: { disabled: true },
calVideoSettings: { sendTranscriptionEmails: true },
interfaceLanguage: "en",
allowReschedulingPastBookings: true,
allowReschedulingCancelledBookings: true,
showOptimizedSlots: true,
};
return request(app.getHttpServer())
@@ -606,6 +636,15 @@ describe("Event types Endpoints", () => {
expect(createdEventType.bookingFields).toEqual(expectedBookingFields);
expect(createdEventType.bookingRequiresAuthentication).toEqual(true);
expect(createdEventType.disableCancelling).toEqual({ disabled: true });
expect(createdEventType.disableRescheduling).toEqual({ disabled: true });
expect(createdEventType.calVideoSettings?.sendTranscriptionEmails).toEqual(true);
expect(createdEventType.interfaceLanguage).toEqual(body.interfaceLanguage);
expect(createdEventType.allowReschedulingPastBookings).toEqual(body.allowReschedulingPastBookings);
expect(createdEventType.allowReschedulingCancelledBookings).toEqual(
body.allowReschedulingCancelledBookings
);
expect(createdEventType.showOptimizedSlots).toEqual(body.showOptimizedSlots);
eventType = responseBody.data;
});
});
@@ -693,6 +732,19 @@ describe("Event types Endpoints", () => {
);
expect(fetchedEventType?.color).toEqual(eventType.color);
expect(fetchedEventType?.hidden).toEqual(false);
expect(fetchedEventType?.disableCancelling).toEqual(eventType.disableCancelling);
expect(fetchedEventType?.disableRescheduling).toEqual(eventType.disableRescheduling);
expect(fetchedEventType?.calVideoSettings?.sendTranscriptionEmails).toEqual(
eventType.calVideoSettings?.sendTranscriptionEmails
);
expect(fetchedEventType?.interfaceLanguage).toEqual(eventType.interfaceLanguage);
expect(fetchedEventType?.allowReschedulingPastBookings).toEqual(
eventType.allowReschedulingPastBookings
);
expect(fetchedEventType?.allowReschedulingCancelledBookings).toEqual(
eventType.allowReschedulingCancelledBookings
);
expect(fetchedEventType?.showOptimizedSlots).toEqual(eventType.showOptimizedSlots);
expect(fetchedHiddenEventType?.id).toEqual(hiddenEventType.id);
expect(fetchedHiddenEventType?.hidden).toEqual(true);
@@ -822,6 +874,19 @@ describe("Event types Endpoints", () => {
);
expect(fetchedEventType?.color).toEqual(eventType.color);
expect(fetchedEventType?.hidden).toEqual(false);
expect(fetchedEventType?.disableCancelling).toEqual(eventType.disableCancelling);
expect(fetchedEventType?.disableRescheduling).toEqual(eventType.disableRescheduling);
expect(fetchedEventType?.calVideoSettings?.sendTranscriptionEmails).toEqual(
eventType.calVideoSettings?.sendTranscriptionEmails
);
expect(fetchedEventType?.interfaceLanguage).toEqual(eventType.interfaceLanguage);
expect(fetchedEventType?.allowReschedulingPastBookings).toEqual(
eventType.allowReschedulingPastBookings
);
expect(fetchedEventType?.allowReschedulingCancelledBookings).toEqual(
eventType.allowReschedulingCancelledBookings
);
expect(fetchedEventType?.showOptimizedSlots).toEqual(eventType.showOptimizedSlots);
});
it(`/GET/event-types by username and eventSlug should not return hidden event type if auth of non event type owner provided`, async () => {
@@ -1209,6 +1274,7 @@ describe("Event types Endpoints", () => {
enableAutomaticTranscription: true,
disableTranscriptionForGuests: true,
disableTranscriptionForOrganizer: true,
sendTranscriptionEmails: false,
},
bookingFields: [
nameBookingField,
@@ -1268,6 +1334,12 @@ describe("Event types Endpoints", () => {
},
customName: `{Event type title} betweennnnnnnnnnn {Organiser} and {Scheduler}`,
bookingRequiresAuthentication: false,
disableCancelling: { disabled: false },
disableRescheduling: { disabled: false, minutesBefore: 60 },
interfaceLanguage: "es",
allowReschedulingPastBookings: false,
allowReschedulingCancelledBookings: false,
showOptimizedSlots: false,
};
return request(app.getHttpServer())
@@ -1374,6 +1446,23 @@ describe("Event types Endpoints", () => {
eventType.calVideoSettings = updatedEventType.calVideoSettings;
expect(updatedEventType.bookingRequiresAuthentication).toEqual(false);
expect(updatedEventType.disableCancelling).toEqual({ disabled: false });
expect(updatedEventType.disableRescheduling).toEqual({ disabled: false, minutesBefore: 60 });
expect(updatedEventType.calVideoSettings?.sendTranscriptionEmails).toEqual(false);
expect(updatedEventType.interfaceLanguage).toEqual(body.interfaceLanguage);
expect(updatedEventType.allowReschedulingPastBookings).toEqual(body.allowReschedulingPastBookings);
expect(updatedEventType.allowReschedulingCancelledBookings).toEqual(
body.allowReschedulingCancelledBookings
);
expect(updatedEventType.showOptimizedSlots).toEqual(body.showOptimizedSlots);
eventType.disableCancelling = updatedEventType.disableCancelling;
eventType.disableRescheduling = updatedEventType.disableRescheduling;
eventType.calVideoSettings = updatedEventType.calVideoSettings;
eventType.interfaceLanguage = updatedEventType.interfaceLanguage;
eventType.allowReschedulingPastBookings = updatedEventType.allowReschedulingPastBookings;
eventType.allowReschedulingCancelledBookings = updatedEventType.allowReschedulingCancelledBookings;
eventType.showOptimizedSlots = updatedEventType.showOptimizedSlots;
});
});
@@ -1408,6 +1497,19 @@ describe("Event types Endpoints", () => {
.expect(400);
});
it("should return an error when updating an event type with invalid interfaceLanguage", async () => {
const body: UpdateEventTypeInput_2024_06_14 = {
interfaceLanguage: "invalid-locale-xyz",
};
return request(app.getHttpServer())
.patch(`/api/v2/event-types/${eventType.id}`)
.set("Authorization", `Bearer ${apiKeyString}`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_06_14)
.send(body)
.expect(400);
});
it(`/GET/:id`, async () => {
const response = await request(app.getHttpServer())
.get(`/api/v2/event-types/${eventType.id}`)
@@ -131,6 +131,9 @@ export class InputEventTypesService_2024_06_14 {
disableGuests,
bookerActiveBookingsLimit,
slug,
disableRescheduling,
disableCancelling,
calVideoSettings,
...rest
} = inputEventType;
const confirmationPolicyTransformed = this.transformInputConfirmationPolicy(confirmationPolicy);
@@ -155,6 +158,10 @@ export class InputEventTypesService_2024_06_14 {
multipleDuration: lengthInMinutesOptions,
};
const disableReschedulingTransformed = this.transformInputDisableRescheduling(disableRescheduling);
const disableCancellingTransformed = this.transformInputDisableCancelling(disableCancelling);
const calVideoSettingsTransformed = this.transformInputCalVideoSettings(calVideoSettings);
const eventType = {
...rest,
slug: slugifiedSlug,
@@ -176,6 +183,9 @@ export class InputEventTypesService_2024_06_14 {
eventName: customName,
useEventTypeDestinationCalendarEmail: useDestinationCalendarEmail,
...maxActiveBookingsPerBooker,
...disableReschedulingTransformed,
...disableCancellingTransformed,
...calVideoSettingsTransformed,
};
return eventType;
@@ -215,6 +225,9 @@ export class InputEventTypesService_2024_06_14 {
disableGuests,
bookerActiveBookingsLimit,
slug,
disableRescheduling,
disableCancelling,
calVideoSettings,
...rest
} = inputEventType;
const eventTypeDb = await this.eventTypesRepository.getEventTypeWithMetaData(eventTypeId);
@@ -247,6 +260,16 @@ export class InputEventTypesService_2024_06_14 {
...(lengthInMinutesOptions !== undefined ? { multipleDuration: lengthInMinutesOptions } : {}),
};
const disableReschedulingTransformed = disableRescheduling
? this.transformInputDisableRescheduling(disableRescheduling)
: {};
const disableCancellingTransformed = disableCancelling
? this.transformInputDisableCancelling(disableCancelling)
: {};
const calVideoSettingsTransformed = calVideoSettings
? this.transformInputCalVideoSettings(calVideoSettings)
: {};
const eventType = {
...rest,
...(slug ? { slug: slugifyLenient(slug) } : {}),
@@ -270,6 +293,9 @@ export class InputEventTypesService_2024_06_14 {
eventName: customName,
useEventTypeDestinationCalendarEmail: useDestinationCalendarEmail,
...maxActiveBookingsPerBooker,
...disableReschedulingTransformed,
...disableCancellingTransformed,
...calVideoSettingsTransformed,
};
return eventType;
@@ -602,4 +628,60 @@ export class InputEventTypesService_2024_06_14 {
}
return foundApp.credential;
}
transformInputDisableRescheduling(disableRescheduling: CreateEventTypeInput_2024_06_14["disableRescheduling"]) {
if (!disableRescheduling) {
return {};
}
// If disabled is true, rescheduling is always disabled
if (disableRescheduling.disabled === true) {
return {
disableRescheduling: true,
minimumRescheduleNotice: null,
};
}
// If minutesBefore is set, use it for conditional disable
if (disableRescheduling.minutesBefore && disableRescheduling.minutesBefore > 0) {
return {
disableRescheduling: false,
minimumRescheduleNotice: disableRescheduling.minutesBefore,
};
}
// Otherwise rescheduling is not disabled
return {
disableRescheduling: false,
minimumRescheduleNotice: null,
};
}
transformInputDisableCancelling(disableCancelling: CreateEventTypeInput_2024_06_14["disableCancelling"]) {
if (!disableCancelling) {
return {};
}
return {
disableCancelling: disableCancelling.disabled === true,
};
}
transformInputCalVideoSettings(calVideoSettings: CreateEventTypeInput_2024_06_14["calVideoSettings"]) {
if (!calVideoSettings) {
return {};
}
// Extract sendTranscriptionEmails from calVideoSettings and map to canSendCalVideoTranscriptionEmails
const { sendTranscriptionEmails, ...restCalVideoSettings } = calVideoSettings;
const hasOtherSettings = Object.keys(restCalVideoSettings).length > 0;
return {
...(hasOtherSettings ? { calVideoSettings: restCalVideoSettings } : {}),
...(sendTranscriptionEmails !== undefined
? { canSendCalVideoTranscriptionEmails: sendTranscriptionEmails }
: {}),
};
}
}
@@ -40,7 +40,7 @@ type EventTypeRelations = {
destinationCalendar?: DestinationCalendar | null;
calVideoSettings?: CalVideoSettings | null;
};
export type DatabaseEventType = Omit<EventType, "allowReschedulingCancelledBookings"> & EventTypeRelations;
export type DatabaseEventType = EventType & EventTypeRelations;
type Input = Pick<
DatabaseEventType,
@@ -94,6 +94,14 @@ type Input = Pick<
| "bookingRequiresAuthentication"
| "maxActiveBookingsPerBooker"
| "maxActiveBookingPerBookerOfferReschedule"
| "disableCancelling"
| "disableRescheduling"
| "minimumRescheduleNotice"
| "canSendCalVideoTranscriptionEmails"
| "interfaceLanguage"
| "allowReschedulingPastBookings"
| "allowReschedulingCancelledBookings"
| "showOptimizedSlots"
>;
@Injectable()
@@ -134,6 +142,14 @@ export class OutputEventTypesService_2024_06_14 {
calVideoSettings,
hidden,
bookingRequiresAuthentication,
disableCancelling,
disableRescheduling,
minimumRescheduleNotice,
canSendCalVideoTranscriptionEmails,
interfaceLanguage,
allowReschedulingPastBookings,
allowReschedulingCancelledBookings,
showOptimizedSlots,
} = databaseEventType;
const locations = this.transformLocations(databaseEventType.locations);
@@ -168,6 +184,15 @@ export class OutputEventTypesService_2024_06_14 {
} as TransformFutureBookingsLimitSchema_2024_06_14);
const destinationCalendar = this.transformDestinationCalendar(databaseEventType.destinationCalendar);
const bookerActiveBookingsLimit = this.transformBookerActiveBookingsLimit(databaseEventType);
const disableReschedulingOutput = this.transformDisableRescheduling(
disableRescheduling,
minimumRescheduleNotice
);
const disableCancellingOutput = this.transformDisableCancelling(disableCancelling);
const calVideoSettingsOutput = this.transformCalVideoSettings(
calVideoSettings,
canSendCalVideoTranscriptionEmails
);
return {
id,
@@ -210,10 +235,16 @@ export class OutputEventTypesService_2024_06_14 {
useDestinationCalendarEmail: useEventTypeDestinationCalendarEmail,
hideCalendarEventDetails,
hideOrganizerEmail,
calVideoSettings,
calVideoSettings: calVideoSettingsOutput,
hidden,
bookingRequiresAuthentication,
bookerActiveBookingsLimit,
disableCancelling: disableCancellingOutput,
disableRescheduling: disableReschedulingOutput,
interfaceLanguage,
allowReschedulingPastBookings,
allowReschedulingCancelledBookings,
showOptimizedSlots,
};
}
@@ -395,4 +426,40 @@ export class OutputEventTypesService_2024_06_14 {
bookingFields: visibleBookingFields,
};
}
transformDisableRescheduling(
disableRescheduling: boolean | null | undefined,
minimumRescheduleNotice: number | null | undefined
) {
// If disableRescheduling is true, rescheduling is always disabled
if (disableRescheduling === true) {
return { disabled: true };
}
// If minimumRescheduleNotice is set, rescheduling is conditionally disabled
if (minimumRescheduleNotice && minimumRescheduleNotice > 0) {
return { disabled: false, minutesBefore: minimumRescheduleNotice };
}
// Otherwise rescheduling is not disabled
return { disabled: false };
}
transformDisableCancelling(disableCancelling: boolean | null | undefined) {
return { disabled: disableCancelling === true };
}
transformCalVideoSettings(
calVideoSettings: CalVideoSettings | null | undefined,
canSendCalVideoTranscriptionEmails: boolean | null | undefined
) {
if (!calVideoSettings && canSendCalVideoTranscriptionEmails === undefined) {
return undefined;
}
return {
...calVideoSettings,
sendTranscriptionEmails: canSendCalVideoTranscriptionEmails ?? true,
};
}
}
@@ -29,6 +29,10 @@ export type InputEventTransformed_2024_06_14 = Omit<
| "seats"
| "customName"
| "useDestinationCalendarEmail"
| "disableRescheduling"
| "disableCancelling"
| "calVideoSettings"
| "bookerActiveBookingsLimit"
> & {
length: number;
slug: string;
@@ -38,10 +42,23 @@ export type InputEventTransformed_2024_06_14 = Omit<
bookingFields?: ReturnType<typeof transformBookingFieldsApiToInternal>;
durationLimits?: ReturnType<typeof transformIntervalLimitsApiToInternal>;
recurringEvent?: ReturnType<typeof transformRecurrenceApiToInternal>;
maxActiveBookingsPerBooker?: number;
maxActiveBookingsPerBooker?: number | null;
maxActiveBookingPerBookerOfferReschedule?: boolean;
eventTypeColor?: ReturnType<typeof transformEventColorsApiToInternal>;
useEventTypeDestinationCalendarEmail?: boolean;
disableRescheduling?: boolean;
disableCancelling?: boolean;
minimumRescheduleNotice?: number | null;
canSendCalVideoTranscriptionEmails?: boolean;
calVideoSettings?: {
disableRecordingForOrganizer?: boolean;
disableRecordingForGuests?: boolean;
redirectUrlOnExit?: string | null;
enableAutomaticRecordingForOrganizer?: boolean;
enableAutomaticTranscription?: boolean;
disableTranscriptionForGuests?: boolean;
disableTranscriptionForOrganizer?: boolean;
};
} & Partial<
Pick<ConfirmationPolicyTransformedSchema, "requiresConfirmation" | "requiresConfirmationWillBlockSlot">
> &
@@ -88,6 +88,14 @@ type Input = Pick<
| "rescheduleWithSameRoundRobinHost"
| "maxActiveBookingPerBookerOfferReschedule"
| "maxActiveBookingsPerBooker"
| "disableCancelling"
| "disableRescheduling"
| "minimumRescheduleNotice"
| "canSendCalVideoTranscriptionEmails"
| "interfaceLanguage"
| "allowReschedulingPastBookings"
| "allowReschedulingCancelledBookings"
| "showOptimizedSlots"
| "rrHostSubsetEnabled"
>;