fix: v2 event-types (#16132)
* refactor: have system and user booking fields schemas and united schema * fix: event-types output service filter out system booking fields for response * chore: v2 update platform-libraries to 0.0.25 * chore: platform-libraries export types and update changelog * chore: add updated lock file
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
"dependencies": {
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2",
|
||||
"@calcom/platform-libraries-0.0.23": "npm:@calcom/platform-libraries@0.0.23",
|
||||
"@calcom/platform-libraries-0.0.26": "npm:@calcom/platform-libraries@0.0.26",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
"@calcom/prisma": "*",
|
||||
|
||||
@@ -20,7 +20,7 @@ import { UserRepositoryFixture } from "test/fixtures/repository/users.repository
|
||||
import { withApiAuth } from "test/utils/withApiAuth";
|
||||
|
||||
import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants";
|
||||
import { handleNewBooking } from "@calcom/platform-libraries-0.0.23";
|
||||
import { handleNewBooking } from "@calcom/platform-libraries-0.0.26";
|
||||
import { ApiSuccessResponse, ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
describe("Bookings Endpoints", () => {
|
||||
|
||||
@@ -46,7 +46,7 @@ import {
|
||||
getBookingInfo,
|
||||
handleCancelBooking,
|
||||
getBookingForReschedule,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
import { GetBookingsInput, CancelBookingInput, Status } from "@calcom/platform-types";
|
||||
import { ApiResponse } from "@calcom/platform-types";
|
||||
import { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CreateBookingInput } from "@/ee/bookings/inputs/create-booking.input";
|
||||
import { IsBoolean, IsNumber, IsOptional } from "class-validator";
|
||||
|
||||
import type { AppsStatus } from "@calcom/platform-libraries-0.0.23";
|
||||
import type { AppsStatus } from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
export class CreateRecurringBookingInput extends CreateBookingInput {
|
||||
@IsBoolean()
|
||||
|
||||
@@ -5,7 +5,7 @@ import { BadRequestException, UnauthorizedException } from "@nestjs/common";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { SUCCESS_STATUS, APPLE_CALENDAR_TYPE, APPLE_CALENDAR_ID } from "@calcom/platform-constants";
|
||||
import { symmetricEncrypt, CalendarService } from "@calcom/platform-libraries-0.0.23";
|
||||
import { symmetricEncrypt, CalendarService } from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
@Injectable()
|
||||
export class AppleCalendarService implements CredentialSyncCalendarApp {
|
||||
|
||||
@@ -18,7 +18,7 @@ import { User } from "@prisma/client";
|
||||
import { DateTime } from "luxon";
|
||||
import { z } from "zod";
|
||||
|
||||
import { getConnectedDestinationCalendars, getBusyCalendarTimes } from "@calcom/platform-libraries-0.0.23";
|
||||
import { getConnectedDestinationCalendars, getBusyCalendarTimes } from "@calcom/platform-libraries-0.0.26";
|
||||
import { Calendar } from "@calcom/platform-types";
|
||||
import { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import {
|
||||
EventTypesPublic,
|
||||
eventTypeBookingFields,
|
||||
eventTypeLocations,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
import { ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
describe("Event types Endpoints", () => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { getEventTypeById } from "@calcom/platform-libraries-0.0.23";
|
||||
import { getEventTypeById } from "@calcom/platform-libraries-0.0.26";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
@Injectable()
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
||||
updateEventType,
|
||||
EventTypesPublic,
|
||||
getEventTypesPublic,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
import { EventType } from "@calcom/prisma/client";
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
getEventTypeById,
|
||||
transformApiEventTypeBookingFields,
|
||||
transformApiEventTypeLocations,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
import { CreateEventTypeInput_2024_06_14 } from "@calcom/platform-types";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
|
||||
+3
-3
@@ -10,9 +10,9 @@ import { UsersService } from "@/modules/users/services/users.service";
|
||||
import { UserWithProfile, UsersRepository } from "@/modules/users/users.repository";
|
||||
import { BadRequestException, ForbiddenException, Injectable, NotFoundException } from "@nestjs/common";
|
||||
|
||||
import { createEventType, updateEventType } from "@calcom/platform-libraries-0.0.23";
|
||||
import { getEventTypesPublic, EventTypesPublic } from "@calcom/platform-libraries-0.0.23";
|
||||
import { dynamicEvent } from "@calcom/platform-libraries-0.0.23";
|
||||
import { createEventType, updateEventType } from "@calcom/platform-libraries-0.0.26";
|
||||
import { getEventTypesPublic, EventTypesPublic } from "@calcom/platform-libraries-0.0.26";
|
||||
import { dynamicEvent } from "@calcom/platform-libraries-0.0.26";
|
||||
import {
|
||||
CreateEventTypeInput_2024_06_14,
|
||||
UpdateEventTypeInput_2024_06_14,
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { Injectable } from "@nestjs/common";
|
||||
import {
|
||||
transformApiEventTypeBookingFields,
|
||||
transformApiEventTypeLocations,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
import { CreateEventTypeInput_2024_06_14, UpdateEventTypeInput_2024_06_14 } from "@calcom/platform-types";
|
||||
|
||||
@Injectable()
|
||||
|
||||
+9
-4
@@ -9,7 +9,9 @@ import {
|
||||
parseRecurringEvent,
|
||||
TransformedLocationsSchema,
|
||||
BookingFieldsSchema,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
SystemField,
|
||||
UserField,
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
type EventTypeRelations = { users: User[]; schedule: Schedule | null };
|
||||
type DatabaseEventType = EventType & EventTypeRelations;
|
||||
@@ -72,7 +74,9 @@ export class OutputEventTypesService_2024_06_14 {
|
||||
} = databaseEventType;
|
||||
|
||||
const locations = this.transformLocations(databaseEventType.locations);
|
||||
const bookingFields = this.transformBookingFields(databaseEventType.bookingFields);
|
||||
const bookingFields = databaseEventType.bookingFields
|
||||
? this.transformBookingFields(BookingFieldsSchema.parse(databaseEventType.bookingFields))
|
||||
: [];
|
||||
const recurringEvent = this.transformRecurringEvent(databaseEventType.recurringEvent);
|
||||
const metadata = this.transformMetadata(databaseEventType.metadata) || {};
|
||||
const users = this.transformUsers(databaseEventType.users);
|
||||
@@ -113,9 +117,10 @@ export class OutputEventTypesService_2024_06_14 {
|
||||
return getResponseEventTypeLocations(TransformedLocationsSchema.parse(locations));
|
||||
}
|
||||
|
||||
transformBookingFields(inputBookingFields: any) {
|
||||
transformBookingFields(inputBookingFields: (SystemField | UserField)[] | null) {
|
||||
if (!inputBookingFields) return [];
|
||||
return getResponseEventTypeBookingFields(BookingFieldsSchema.parse(inputBookingFields));
|
||||
const userFields = inputBookingFields.filter((field) => field.editable === "user") as UserField[];
|
||||
return getResponseEventTypeBookingFields(userFields);
|
||||
}
|
||||
|
||||
transformRecurringEvent(recurringEvent: any) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { Injectable } from "@nestjs/common";
|
||||
import {
|
||||
transformApiScheduleOverrides,
|
||||
transformApiScheduleAvailability,
|
||||
} from "@calcom/platform-libraries-0.0.23";
|
||||
} from "@calcom/platform-libraries-0.0.26";
|
||||
import { CreateScheduleInput_2024_06_11, ScheduleAvailabilityInput_2024_06_11 } from "@calcom/platform-types";
|
||||
import { ScheduleOverrideInput_2024_06_11 } from "@calcom/platform-types";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ArgumentsHost, Catch, ExceptionFilter, Logger } from "@nestjs/common";
|
||||
import { Request } from "express";
|
||||
|
||||
import { ERROR_STATUS } from "@calcom/platform-constants";
|
||||
import { TRPCError } from "@calcom/platform-libraries-0.0.23";
|
||||
import { TRPCError } from "@calcom/platform-libraries-0.0.26";
|
||||
import { Response } from "@calcom/platform-types";
|
||||
|
||||
@Catch(TRPCError)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { sendSignupToOrganizationEmail, getTranslation } from "@calcom/platform-libraries-0.0.23";
|
||||
import { sendSignupToOrganizationEmail, getTranslation } from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
@Injectable()
|
||||
export class EmailService {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { UsersRepository } from "@/modules/users/users.repository";
|
||||
import { BadRequestException, Injectable } from "@nestjs/common";
|
||||
import { User } from "@prisma/client";
|
||||
|
||||
import { createNewUsersConnectToOrgIfExists, slugify } from "@calcom/platform-libraries-0.0.23";
|
||||
import { createNewUsersConnectToOrgIfExists, slugify } from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
@Injectable()
|
||||
export class OAuthClientUsersService {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
|
||||
import { createEventType, updateEventType } from "@calcom/platform-libraries-0.0.23";
|
||||
import { createEventType, updateEventType } from "@calcom/platform-libraries-0.0.26";
|
||||
import {
|
||||
CreateTeamEventTypeInput_2024_06_14,
|
||||
UpdateTeamEventTypeInput_2024_06_14,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { OrganizationsTeamsRepository } from "@/modules/organizations/repositori
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { updateNewTeamMemberEventTypes } from "@calcom/platform-libraries-0.0.23";
|
||||
import { updateNewTeamMemberEventTypes } from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
@Injectable()
|
||||
export class OrganizationsTeamsService {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CreateUserInput } from "@/modules/users/inputs/create-user.input";
|
||||
import { Injectable, ConflictException } from "@nestjs/common";
|
||||
import { plainToInstance } from "class-transformer";
|
||||
|
||||
import { createNewUsersConnectToOrgIfExists } from "@calcom/platform-libraries-0.0.23";
|
||||
import { createNewUsersConnectToOrgIfExists } from "@calcom/platform-libraries-0.0.26";
|
||||
import { Team } from "@calcom/prisma/client";
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -5,8 +5,8 @@ import { ApiTags as DocsTags } from "@nestjs/swagger";
|
||||
import { Response as ExpressResponse, Request as ExpressRequest } from "express";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import { getAvailableSlots } from "@calcom/platform-libraries-0.0.23";
|
||||
import type { AvailableSlotsType } from "@calcom/platform-libraries-0.0.23";
|
||||
import { getAvailableSlots } from "@calcom/platform-libraries-0.0.26";
|
||||
import type { AvailableSlotsType } from "@calcom/platform-libraries-0.0.26";
|
||||
import { RemoveSelectedSlotInput, ReserveSlotInput } from "@calcom/platform-types";
|
||||
import { ApiResponse, GetAvailableSlotsInput } from "@calcom/platform-types";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
import { MINUTES_TO_BOOK } from "@calcom/platform-libraries-0.0.23";
|
||||
import { MINUTES_TO_BOOK } from "@calcom/platform-libraries-0.0.26";
|
||||
import { ReserveSlotInput } from "@calcom/platform-types";
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Controller, Get } from "@nestjs/common";
|
||||
import { ApiTags as DocsTags } from "@nestjs/swagger";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { CityTimezones } from "@calcom/platform-libraries-0.0.23";
|
||||
import type { CityTimezones } from "@calcom/platform-libraries-0.0.26";
|
||||
import { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
@Controller({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { RedisService } from "@/modules/redis/redis.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { cityTimezonesHandler } from "@calcom/platform-libraries-0.0.23";
|
||||
import type { CityTimezones } from "@calcom/platform-libraries-0.0.23";
|
||||
import { cityTimezonesHandler } from "@calcom/platform-libraries-0.0.26";
|
||||
import type { CityTimezones } from "@calcom/platform-libraries-0.0.26";
|
||||
|
||||
@Injectable()
|
||||
export class TimezonesService {
|
||||
|
||||
@@ -1219,6 +1219,16 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateScheduleInput_2024_06_11"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "",
|
||||
@@ -1321,6 +1331,16 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateScheduleInput_2024_06_11"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
@@ -2360,6 +2380,16 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateScheduleInput_2024_04_15"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
@@ -5841,6 +5871,57 @@
|
||||
"data"
|
||||
]
|
||||
},
|
||||
"CreateScheduleInput_2024_06_11": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "One-on-one coaching"
|
||||
},
|
||||
"timeZone": {
|
||||
"type": "string",
|
||||
"example": "Europe/Rome"
|
||||
},
|
||||
"availability": {
|
||||
"example": [
|
||||
{
|
||||
"days": [
|
||||
"Monday",
|
||||
"Tuesday"
|
||||
],
|
||||
"startTime": "09:00",
|
||||
"endTime": "10:00"
|
||||
}
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ScheduleAvailabilityInput_2024_06_11"
|
||||
}
|
||||
},
|
||||
"isDefault": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"overrides": {
|
||||
"example": [
|
||||
{
|
||||
"date": "2024-05-20",
|
||||
"startTime": "12:00",
|
||||
"endTime": "14:00"
|
||||
}
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ScheduleOverrideInput_2024_06_11"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"timeZone",
|
||||
"isDefault"
|
||||
]
|
||||
},
|
||||
"CreateScheduleOutput_2024_06_11": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5889,6 +5970,52 @@
|
||||
"data"
|
||||
]
|
||||
},
|
||||
"UpdateScheduleInput_2024_06_11": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "One-on-one coaching"
|
||||
},
|
||||
"timeZone": {
|
||||
"type": "string",
|
||||
"example": "Europe/Rome"
|
||||
},
|
||||
"availability": {
|
||||
"example": [
|
||||
{
|
||||
"days": [
|
||||
"Monday",
|
||||
"Tuesday"
|
||||
],
|
||||
"startTime": "09:00",
|
||||
"endTime": "10:00"
|
||||
}
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ScheduleAvailabilityInput_2024_06_11"
|
||||
}
|
||||
},
|
||||
"isDefault": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"overrides": {
|
||||
"example": [
|
||||
{
|
||||
"date": "2024-05-20",
|
||||
"startTime": "12:00",
|
||||
"endTime": "14:00"
|
||||
}
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ScheduleOverrideInput_2024_06_11"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"UpdateScheduleOutput_2024_06_11": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -6983,6 +7110,26 @@
|
||||
"userId"
|
||||
]
|
||||
},
|
||||
"GetDefaultScheduleOutput_2024_06_11": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"example": "success",
|
||||
"enum": [
|
||||
"success",
|
||||
"error"
|
||||
]
|
||||
},
|
||||
"data": {
|
||||
"$ref": "#/components/schemas/ScheduleOutput_2024_06_11"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"status",
|
||||
"data"
|
||||
]
|
||||
},
|
||||
"CreateAvailabilityInput_2024_04_15": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -7280,6 +7427,66 @@
|
||||
"data"
|
||||
]
|
||||
},
|
||||
"UpdateScheduleInput_2024_04_15": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"timeZone": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"isDefault": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"schedule": {
|
||||
"example": [
|
||||
[],
|
||||
[
|
||||
{
|
||||
"start": "2022-01-01T00:00:00.000Z",
|
||||
"end": "2022-01-02T00:00:00.000Z"
|
||||
}
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
],
|
||||
"items": {
|
||||
"type": "array"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"dateOverrides": {
|
||||
"example": [
|
||||
[],
|
||||
[
|
||||
{
|
||||
"start": "2022-01-01T00:00:00.000Z",
|
||||
"end": "2022-01-02T00:00:00.000Z"
|
||||
}
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
],
|
||||
"items": {
|
||||
"type": "array"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"timeZone",
|
||||
"name",
|
||||
"isDefault",
|
||||
"schedule"
|
||||
]
|
||||
},
|
||||
"EventTypeModel_2024_04_15": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -8544,9 +8751,6 @@
|
||||
"noShowHost": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"messageKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"attendees": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -267,7 +267,7 @@ export default class Office365CalendarService implements Calendar {
|
||||
subject: event.title,
|
||||
body: {
|
||||
contentType: "HTML",
|
||||
content: getRichDescription(event),
|
||||
content: getRichDescription(event).replace(/\n/g, "<br>"),
|
||||
},
|
||||
start: {
|
||||
dateTime: dayjs(event.startTime).tz(event.organizer.timeZone).format("YYYY-MM-DDTHH:mm:ss"),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { BookingField_2024_06_14, Location_2024_06_14 } from "@calcom/platform-types";
|
||||
|
||||
import type { CommonField, OptionsField } from "./api-request";
|
||||
import type { UserField, OptionsField } from "./api-request";
|
||||
import {
|
||||
transformApiEventTypeLocations,
|
||||
transformApiEventTypeBookingFields,
|
||||
@@ -90,7 +90,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -125,7 +125,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -160,7 +160,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -195,7 +195,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -230,7 +230,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -265,7 +265,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -300,7 +300,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -408,7 +408,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
@@ -514,7 +514,7 @@ describe("transformApiEventTypeBookingFields", () => {
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
const expectedOutput: UserField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
|
||||
@@ -70,7 +70,7 @@ function transformApiEventTypeBookingFields(
|
||||
}
|
||||
|
||||
const customBookingFields = inputBookingFields.map((field) => {
|
||||
const commonFields: CommonField = {
|
||||
const commonFields: UserField = {
|
||||
name: field.slug,
|
||||
type: field.type,
|
||||
label: field.label,
|
||||
@@ -126,7 +126,7 @@ const FieldTypeEnum = z.enum([
|
||||
"radioInput",
|
||||
]);
|
||||
|
||||
const CommonFieldsSchema = z.object({
|
||||
const UserFieldsSchema = z.object({
|
||||
name: z.string(),
|
||||
type: FieldTypeEnum,
|
||||
label: z.string(),
|
||||
@@ -141,13 +141,21 @@ const CommonFieldsSchema = z.object({
|
||||
editable: z.literal("user"),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string().optional(),
|
||||
options: z
|
||||
.array(
|
||||
z.object({
|
||||
label: z.string(),
|
||||
value: z.string(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const SystemFieldsSchema = z.object({
|
||||
name: z.string(),
|
||||
type: FieldTypeEnum,
|
||||
defaultLabel: z.string(),
|
||||
labe: z.string().optional(),
|
||||
label: z.string().optional(),
|
||||
editable: z.enum(["system-but-optional", "system"]),
|
||||
sources: z.array(
|
||||
z.object({
|
||||
@@ -187,18 +195,8 @@ const SystemFieldsSchema = z.object({
|
||||
|
||||
export type SystemField = z.infer<typeof SystemFieldsSchema>;
|
||||
|
||||
export type CommonField = z.infer<typeof CommonFieldsSchema>;
|
||||
export type UserField = z.infer<typeof UserFieldsSchema>;
|
||||
|
||||
const OptionSchema = z.object({
|
||||
label: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
const BookingFieldSchema = CommonFieldsSchema.extend({
|
||||
options: z.array(OptionSchema).optional(),
|
||||
});
|
||||
export type OptionsField = z.infer<typeof BookingFieldSchema>;
|
||||
|
||||
export const BookingFieldsSchema = z.array(BookingFieldSchema);
|
||||
export const BookingFieldsSchema = z.array(z.union([UserFieldsSchema, SystemFieldsSchema]));
|
||||
|
||||
export { transformApiEventTypeLocations, transformApiEventTypeBookingFields };
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
IntegrationLocation_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import type { CommonField, OptionsField } from "./api-request";
|
||||
import type { UserField, OptionsField } from "./api-request";
|
||||
import { getResponseEventTypeLocations, getResponseEventTypeBookingFields } from "./api-response";
|
||||
|
||||
describe("getResponseEventTypeLocations", () => {
|
||||
@@ -99,7 +99,7 @@ describe("getResponseEventTypeLocations", () => {
|
||||
|
||||
describe("getResponseEventTypeBookingFields", () => {
|
||||
it("should reverse transform name field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-name",
|
||||
type: "name",
|
||||
@@ -134,7 +134,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform email field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-email",
|
||||
type: "email",
|
||||
@@ -169,7 +169,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform phone field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-phone",
|
||||
type: "phone",
|
||||
@@ -204,7 +204,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform address field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-address",
|
||||
type: "address",
|
||||
@@ -239,7 +239,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform text field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-text",
|
||||
type: "text",
|
||||
@@ -274,7 +274,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform number field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-number",
|
||||
type: "number",
|
||||
@@ -309,7 +309,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform textarea field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-textarea",
|
||||
type: "textarea",
|
||||
@@ -422,7 +422,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform multiemail field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "your-multiemail",
|
||||
type: "multiemail",
|
||||
@@ -533,7 +533,7 @@ describe("getResponseEventTypeBookingFields", () => {
|
||||
});
|
||||
|
||||
it("should reverse transform boolean field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
const transformedField: UserField[] = [
|
||||
{
|
||||
name: "agree-to-terms",
|
||||
type: "boolean",
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
LinkLocation_2024_06_14,
|
||||
PhoneLocation_2024_06_14,
|
||||
Integration_2024_06_14,
|
||||
BookingField_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import type { transformApiEventTypeBookingFields, transformApiEventTypeLocations } from "./api-request";
|
||||
@@ -71,7 +72,7 @@ function getResponseEventTypeLocations(
|
||||
|
||||
function getResponseEventTypeBookingFields(
|
||||
transformedBookingFields: ReturnType<typeof transformApiEventTypeBookingFields>
|
||||
) {
|
||||
): BookingField_2024_06_14[] {
|
||||
if (!transformedBookingFields) {
|
||||
return [];
|
||||
}
|
||||
@@ -156,7 +157,7 @@ function getResponseEventTypeBookingFields(
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
options: field.options ? field.options.map((option) => option.value) : [],
|
||||
};
|
||||
case "multiselect":
|
||||
return {
|
||||
@@ -164,7 +165,7 @@ function getResponseEventTypeBookingFields(
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
options: field.options ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
case "checkbox":
|
||||
return {
|
||||
@@ -172,7 +173,7 @@ function getResponseEventTypeBookingFields(
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
options: field.options ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
case "radio":
|
||||
return {
|
||||
@@ -180,7 +181,7 @@ function getResponseEventTypeBookingFields(
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
options: field.options ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
default:
|
||||
throw new Error(`Unsupported booking field type '${field.type}'.`);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
## 0.0.26
|
||||
Update `packages/app-store/office365calendar/lib/CalendarService.ts` "translateEvent" content so that in microsoft outlook calendar event the description
|
||||
has newlines instead of being all in 1 line.
|
||||
|
||||
## 0.0.25
|
||||
Refactor "packages/lib/event-types/transformers/api-request.ts" getResponseEventTypeBookingFields - make sure that booking fields with options don't have
|
||||
undefines options.
|
||||
|
||||
|
||||
## 0.0.24
|
||||
Refactor "packages/lib/event-types/transformers/api-request.ts" - we access event-type booking fields in database and then distinguish them as either
|
||||
created by the user or system. Then in v2 api "event-types_2024_06_14/services/output-event-types.service.ts" we first parse them and then filter
|
||||
out only user fields. This is done because when creating an event-type we only store user passed booking fields, but if someone already had created
|
||||
booking-fields using event-types version 2024_04_15, then they contained system fields which is why event-types 2024_06_14 controller was failing.
|
||||
|
||||
## 0.0.23
|
||||
Update "createBooking" (packages/features/bookings/lib/handleNewBooking/createBooking.ts) that is used by handleNewBooking (packages/features/bookings/lib/handleNewBooking.ts) to correctly handle metadata of a re-scheduled booking. Previously,
|
||||
metadata of original booking was overwriting metadata in the request body of the new booking (rescheduled), but now
|
||||
|
||||
@@ -100,6 +100,8 @@ export {
|
||||
BookingFieldsSchema,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
|
||||
export type { SystemField, UserField } from "@calcom/lib/event-types/transformers";
|
||||
|
||||
export { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
|
||||
export { dynamicEvent } from "@calcom/lib/defaultEvents";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user