feat: extend api/v2/event-types (#16128)
* feat: extended api/v2/event-types to add more attributes - additional attributes added * bookingLimits * onlyShowFirstAvailableSlot * durationLimits * offsetStart * bookingWindow * add swagger docs * type fix * extend api/v2/teams/[teamId]/event-types * added tests * extend api/v2/orgs/[orgId]/teams/[teamid]/event-types * update: added tests to get and update event-type as well * rename variables - bookingLimits -> bookingLimitsCount - durationLimits -> bookingLimitsDuration * refactor: rename bookingLimits and durationLimits, add descriptions - Renamed `bookingLimits` to `bookingLimitsCount` - Renamed `durationLimits` to `bookingLimitsDuration` - Added descriptions with examples to `bookingLimitsCount` and `bookingLimitsDuration` * feat: add unit tests for transformation logic in api-request and api-response - Added tests for `transformApiEventTypeIntervalLimits` - Added tests for `transformApiEventTypeFutureBookingLimits` * fix: type errors * feat: added custom validators for BookingLimitsCount and BookingLimitsDuration * fix: unit-tests * Update CHANGELOG.md * refactor: update imports to use platform-libraries from @calcom/platform-libraries-1.2.3 * fix: prevent double transformation of bookingWindow and bookingFields - resolving e2e test failures --------- Co-authored-by: Morgan <[email protected]>
This commit is contained in:
1 parent
894c0fc8a7
commit
8fbc76d59a
28 files changed
+1261
-5956
No files matched your search
+21
@@ -24,6 +24,7 @@ import {
|
||||
TeamEventTypeOutput_2024_06_14,
|
||||
UpdateTeamEventTypeInput_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
import { BookingWindowPeriodInputTypeEnum_2024_06_14 } from "@calcom/platform-types/event-types/event-types_2024_06_14/inputs/enums/booking-window.enum";
|
||||
import { Team } from "@calcom/prisma/client";
|
||||
|
||||
describe("Organizations Event Types Endpoints", () => {
|
||||
@@ -260,6 +261,21 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
userId: teammate2.id,
|
||||
},
|
||||
],
|
||||
bookingLimitsCount: {
|
||||
day: 2,
|
||||
week: 5,
|
||||
},
|
||||
onlyShowFirstAvailableSlot: true,
|
||||
bookingLimitsDuration: {
|
||||
day: 60,
|
||||
week: 100,
|
||||
},
|
||||
offsetStart: 30,
|
||||
bookingWindow: {
|
||||
type: BookingWindowPeriodInputTypeEnum_2024_06_14.calendarDays,
|
||||
value: 30,
|
||||
rolling: true,
|
||||
},
|
||||
};
|
||||
|
||||
return request(app.getHttpServer())
|
||||
@@ -276,6 +292,11 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
expect(data.schedulingType).toEqual("COLLECTIVE");
|
||||
evaluateHost(body.hosts[0], data.hosts[0]);
|
||||
evaluateHost(body.hosts[1], data.hosts[1]);
|
||||
expect(data.bookingLimitsCount).toEqual(body.bookingLimitsCount);
|
||||
expect(data.onlyShowFirstAvailableSlot).toEqual(body.onlyShowFirstAvailableSlot);
|
||||
expect(data.bookingLimitsDuration).toEqual(body.bookingLimitsDuration);
|
||||
expect(data.offsetStart).toEqual(body.offsetStart);
|
||||
expect(data.bookingWindow).toEqual(body.bookingWindow);
|
||||
|
||||
collectiveEventType = responseBody.data;
|
||||
});
|
||||
|
||||
@@ -23,7 +23,15 @@ export class InputOrganizationsEventTypesService {
|
||||
teamId: number,
|
||||
inputEventType: CreateTeamEventTypeInput_2024_06_14
|
||||
) {
|
||||
const { hosts, assignAllTeamMembers, ...rest } = inputEventType;
|
||||
const {
|
||||
hosts,
|
||||
assignAllTeamMembers,
|
||||
bookingLimitsCount,
|
||||
bookingLimitsDuration,
|
||||
bookingWindow,
|
||||
bookingFields,
|
||||
...rest
|
||||
} = inputEventType;
|
||||
|
||||
const eventType = this.inputEventTypesService.transformInputCreateEventType(rest);
|
||||
|
||||
@@ -35,6 +43,10 @@ export class InputOrganizationsEventTypesService {
|
||||
? await this.getAllTeamMembers(teamId, inputEventType.schedulingType)
|
||||
: this.transformInputHosts(hosts, inputEventType.schedulingType),
|
||||
assignAllTeamMembers,
|
||||
bookingLimitsCount,
|
||||
bookingLimitsDuration,
|
||||
bookingWindow,
|
||||
bookingFields,
|
||||
metadata,
|
||||
};
|
||||
|
||||
|
||||
+21
-5
@@ -36,11 +36,19 @@ export class OrganizationsEventTypesService {
|
||||
) {
|
||||
await this.validateHosts(teamId, body.hosts);
|
||||
const eventTypeUser = await this.getUserToCreateTeamEvent(user, orgId);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { hosts, assignAllTeamMembers, ...rest } =
|
||||
await this.inputService.transformInputCreateTeamEventType(teamId, body);
|
||||
const {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
hosts,
|
||||
assignAllTeamMembers,
|
||||
locations,
|
||||
bookingLimitsCount,
|
||||
bookingLimitsDuration,
|
||||
bookingWindow,
|
||||
bookingFields,
|
||||
...rest
|
||||
} = await this.inputService.transformInputCreateTeamEventType(teamId, body);
|
||||
const { eventType: eventTypeCreated } = await createEventType({
|
||||
input: { teamId: teamId, ...rest },
|
||||
input: { teamId: teamId, locations, ...rest },
|
||||
ctx: {
|
||||
user: eventTypeUser,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
@@ -52,7 +60,15 @@ export class OrganizationsEventTypesService {
|
||||
return await this.updateTeamEventType(
|
||||
eventTypeCreated.id,
|
||||
teamId,
|
||||
{ hosts: body.hosts, assignAllTeamMembers },
|
||||
{
|
||||
hosts: body.hosts,
|
||||
assignAllTeamMembers,
|
||||
bookingLimitsCount,
|
||||
bookingLimitsDuration,
|
||||
bookingWindow,
|
||||
bookingFields,
|
||||
...rest,
|
||||
},
|
||||
user
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ type Input = Pick<
|
||||
| "userId"
|
||||
| "parentId"
|
||||
| "assignAllTeamMembers"
|
||||
| "bookingLimits"
|
||||
| "durationLimits"
|
||||
| "onlyShowFirstAvailableSlot"
|
||||
| "offsetStart"
|
||||
| "periodType"
|
||||
| "periodDays"
|
||||
| "periodCountCalendarDays"
|
||||
| "periodStartDate"
|
||||
| "periodEndDate"
|
||||
>;
|
||||
|
||||
@Injectable()
|
||||
|
||||
Reference in new issue
Block a user