Skip to content

Commit 420de29

Browse files
Merge branch 'main' into dub-folders
2 parents 5aec1c7 + 5c6f52f commit 420de29

File tree

175 files changed

+19095
-13315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+19095
-13315
lines changed

.yarn/versions/97a32d13.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
undecided:
2+
- "@calcom/app-store-cli"
3+
- "@calcom/platform-constants"
4+
- "@calcom/platform-enums"
5+
- "@calcom/platform-types"
6+
- "@calcom/platform-utils"

apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
167167
timeZone: "Europe/Rome",
168168
},
169169
},
170+
rating: 10,
170171
});
171172

172173
app = moduleRef.createNestApplication();
@@ -552,6 +553,30 @@ describe("Bookings Endpoints 2024-08-13", () => {
552553
});
553554
});
554555

556+
it("should should get a booking with rating", async () => {
557+
return request(app.getHttpServer())
558+
.get(`/v2/bookings/${bookingInThePast.uid}`)
559+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
560+
.expect(200)
561+
.then(async (response) => {
562+
const responseBody: GetBookingOutput_2024_08_13 = response.body;
563+
expect(responseBody.status).toEqual(SUCCESS_STATUS);
564+
expect(responseBody.data).toBeDefined();
565+
expect(responseDataIsBooking(responseBody.data)).toBe(true);
566+
567+
if (responseDataIsBooking(responseBody.data)) {
568+
const data: BookingOutput_2024_08_13 = responseBody.data;
569+
expect(data.id).toEqual(bookingInThePast.id);
570+
expect(data.uid).toEqual(bookingInThePast.uid);
571+
expect(data.rating).toEqual(bookingInThePast.rating);
572+
} else {
573+
throw new Error(
574+
"Invalid response data - expected booking but received array of possibily recurring bookings"
575+
);
576+
}
577+
});
578+
});
579+
555580
it("should should get 1 recurrence of a recurring booking", async () => {
556581
const recurrenceUid = createdRecurringBooking[0].uid;
557582
return request(app.getHttpServer())

apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export class OutputBookingsService_2024_08_13 {
133133
absentHost: !!databaseBooking.noShowHost,
134134
createdAt: databaseBooking.createdAt,
135135
updatedAt: databaseBooking.updatedAt,
136+
rating: databaseBooking.rating,
136137
};
137138

138139
const bookingTransformed = plainToClass(BookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
@@ -227,6 +228,7 @@ export class OutputBookingsService_2024_08_13 {
227228
bookingFieldsResponses: databaseBooking.responses,
228229
createdAt: databaseBooking.createdAt,
229230
updatedAt: databaseBooking.updatedAt,
231+
rating: databaseBooking.rating,
230232
};
231233

232234
const bookingTransformed = plainToClass(RecurringBookingOutput_2024_08_13, booking, {
@@ -274,6 +276,7 @@ export class OutputBookingsService_2024_08_13 {
274276
absentHost: !!databaseBooking.noShowHost,
275277
createdAt: databaseBooking.createdAt,
276278
updatedAt: databaseBooking.updatedAt,
279+
rating: databaseBooking.rating,
277280
};
278281

279282
const parsed = plainToClass(GetSeatedBookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
@@ -283,7 +286,8 @@ export class OutputBookingsService_2024_08_13 {
283286
const { responses } = safeParse(
284287
seatedBookingDataSchema,
285288
attendee.bookingSeat?.data,
286-
defaultSeatedBookingData
289+
defaultSeatedBookingData,
290+
false
287291
);
288292

289293
const attendeeData = {
@@ -300,7 +304,8 @@ export class OutputBookingsService_2024_08_13 {
300304
attendeeParsed.metadata = safeParse(
301305
seatedBookingMetadataSchema,
302306
attendee.bookingSeat?.metadata,
303-
defaultSeatedBookingMetadata
307+
defaultSeatedBookingMetadata,
308+
false
304309
);
305310
// note(Lauris): as of now email is not returned for privacy
306311
delete attendeeParsed.bookingFieldsResponses.email;
@@ -380,6 +385,7 @@ export class OutputBookingsService_2024_08_13 {
380385
absentHost: !!databaseBooking.noShowHost,
381386
createdAt: databaseBooking.createdAt,
382387
updatedAt: databaseBooking.updatedAt,
388+
rating: databaseBooking.rating,
383389
};
384390

385391
const parsed = plainToClass(GetRecurringSeatedBookingOutput_2024_08_13, booking, {
@@ -391,7 +397,8 @@ export class OutputBookingsService_2024_08_13 {
391397
const { responses } = safeParse(
392398
seatedBookingDataSchema,
393399
attendee.bookingSeat?.data,
394-
defaultSeatedBookingData
400+
defaultSeatedBookingData,
401+
false
395402
);
396403

397404
const attendeeData = {
@@ -408,7 +415,8 @@ export class OutputBookingsService_2024_08_13 {
408415
attendeeParsed.metadata = safeParse(
409416
seatedBookingMetadataSchema,
410417
attendee.bookingSeat?.metadata,
411-
defaultSeatedBookingMetadata
418+
defaultSeatedBookingMetadata,
419+
false
412420
);
413421
// note(Lauris): as of now email is not returned for privacy
414422
delete attendeeParsed.bookingFieldsResponses.email;

apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts

+28-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
Post,
3535
Body,
3636
} from "@nestjs/common";
37-
import { ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger";
37+
import { ApiOperation, ApiParam, ApiTags as DocsTags } from "@nestjs/swagger";
3838
import { User } from "@prisma/client";
3939
import { plainToClass } from "class-transformer";
4040
import { Request } from "express";
@@ -123,10 +123,15 @@ export class CalendarsController {
123123
};
124124
}
125125

126+
@ApiParam({
127+
enum: [OFFICE_365_CALENDAR, GOOGLE_CALENDAR],
128+
type: String,
129+
name: "calendar",
130+
})
126131
@UseGuards(ApiAuthGuard)
127132
@Get("/:calendar/connect")
128133
@HttpCode(HttpStatus.OK)
129-
@ApiOperation({ summary: "Get connect URL" })
134+
@ApiOperation({ summary: "Get oAuth connect URL" })
130135
async redirect(
131136
@Req() req: Request,
132137
@Headers("Authorization") authorization: string,
@@ -146,10 +151,15 @@ export class CalendarsController {
146151
}
147152
}
148153

154+
@ApiParam({
155+
enum: [OFFICE_365_CALENDAR, GOOGLE_CALENDAR],
156+
type: String,
157+
name: "calendar",
158+
})
149159
@Get("/:calendar/save")
150160
@HttpCode(HttpStatus.OK)
151161
@Redirect(undefined, 301)
152-
@ApiOperation({ summary: "Save a calendar" })
162+
@ApiOperation({ summary: "Save an oAuth calendar credentials" })
153163
async save(
154164
@Query("state") state: string,
155165
@Query("code") code: string,
@@ -177,6 +187,11 @@ export class CalendarsController {
177187
}
178188
}
179189

190+
@ApiParam({
191+
enum: [APPLE_CALENDAR],
192+
type: String,
193+
name: "calendar",
194+
})
180195
@UseGuards(ApiAuthGuard)
181196
@Post("/:calendar/credentials")
182197
@ApiOperation({ summary: "Sync credentials" })
@@ -198,6 +213,11 @@ export class CalendarsController {
198213
}
199214
}
200215

216+
@ApiParam({
217+
enum: [APPLE_CALENDAR, GOOGLE_CALENDAR, OFFICE_365_CALENDAR],
218+
type: String,
219+
name: "calendar",
220+
})
201221
@Get("/:calendar/check")
202222
@HttpCode(HttpStatus.OK)
203223
@UseGuards(ApiAuthGuard, PermissionsGuard)
@@ -219,6 +239,11 @@ export class CalendarsController {
219239
}
220240
}
221241

242+
@ApiParam({
243+
enum: [APPLE_CALENDAR, GOOGLE_CALENDAR, OFFICE_365_CALENDAR],
244+
type: String,
245+
name: "calendar",
246+
})
222247
@UseGuards(ApiAuthGuard)
223248
@Post("/:calendar/disconnect")
224249
@HttpCode(HttpStatus.OK)

apps/api/v2/src/lib/safe-parse/safe-parse.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@ import { ZodSchema } from "zod";
33

44
const logger = new Logger("safeParse");
55

6-
export function safeParse<T>(schema: ZodSchema<T>, value: unknown, defaultValue: T): T {
6+
export function safeParse<T>(
7+
schema: ZodSchema<T>,
8+
value: unknown,
9+
defaultValue: T,
10+
logError = true
11+
): T {
712
const result = schema.safeParse(value);
813
if (result.success) {
914
return result.data;
1015
} else {
1116
const errorStack = new Error().stack;
1217

13-
logger.error(
14-
`Zod parsing failed.\n` +
15-
`1. Schema: ${schema.description || "UnnamedSchema"}\n` +
16-
`2. Input: ${JSON.stringify(value, null, 2)}\n` +
17-
`3. Zod Error: ${result.error}\n` +
18-
`4. Call Stack: ${errorStack}`
19-
);
18+
if (logError) {
19+
logger.error(
20+
`Zod parsing failed.\n` +
21+
`1. Schema: ${schema.description || "UnnamedSchema"}\n` +
22+
`2. Input: ${JSON.stringify(value, null, 2)}\n` +
23+
`3. Zod Error: ${result.error}\n` +
24+
`4. Call Stack: ${errorStack}`
25+
);
26+
}
2027

2128
return defaultValue;
2229
}

apps/api/v2/src/modules/router/controllers/router.controller.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ export class RouterController {
6565
const pathNameParams = routingUrl.pathname.split("/");
6666
const eventTypeSlug = pathNameParams[pathNameParams.length - 1];
6767
const teamId = Number(routingSearchParams.get("cal.teamId"));
68-
const eventTypeData = this.teamsEventTypesRepository.getTeamEventTypeBySlug(teamId, eventTypeSlug, 3);
68+
const eventTypeData = await this.teamsEventTypesRepository.getTeamEventTypeBySlug(
69+
teamId,
70+
eventTypeSlug,
71+
3
72+
);
6973

7074
// get the salesforce record owner email for the email given as a form response.
7175
const {

apps/api/v2/swagger/documentation.json

+48-4
Original file line numberDiff line numberDiff line change
@@ -4063,7 +4063,7 @@
40634063
"/v2/calendars/{calendar}/connect": {
40644064
"get": {
40654065
"operationId": "CalendarsController_redirect",
4066-
"summary": "Get connect URL",
4066+
"summary": "Get oAuth connect URL",
40674067
"parameters": [
40684068
{
40694069
"name": "Authorization",
@@ -4078,6 +4078,10 @@
40784078
"required": true,
40794079
"in": "path",
40804080
"schema": {
4081+
"enum": [
4082+
"office365",
4083+
"google"
4084+
],
40814085
"type": "string"
40824086
}
40834087
}
@@ -4102,7 +4106,7 @@
41024106
"/v2/calendars/{calendar}/save": {
41034107
"get": {
41044108
"operationId": "CalendarsController_save",
4105-
"summary": "Save a calendar",
4109+
"summary": "Save an oAuth calendar credentials",
41064110
"parameters": [
41074111
{
41084112
"name": "state",
@@ -4125,6 +4129,10 @@
41254129
"required": true,
41264130
"in": "path",
41274131
"schema": {
4132+
"enum": [
4133+
"office365",
4134+
"google"
4135+
],
41284136
"type": "string"
41294137
}
41304138
}
@@ -4149,6 +4157,9 @@
41494157
"required": true,
41504158
"in": "path",
41514159
"schema": {
4160+
"enum": [
4161+
"apple"
4162+
],
41524163
"type": "string"
41534164
}
41544165
}
@@ -4173,6 +4184,11 @@
41734184
"required": true,
41744185
"in": "path",
41754186
"schema": {
4187+
"enum": [
4188+
"apple",
4189+
"google",
4190+
"office365"
4191+
],
41764192
"type": "string"
41774193
}
41784194
}
@@ -4204,6 +4220,11 @@
42044220
"required": true,
42054221
"in": "path",
42064222
"schema": {
4223+
"enum": [
4224+
"apple",
4225+
"google",
4226+
"office365"
4227+
],
42074228
"type": "string"
42084229
}
42094230
}
@@ -12698,8 +12719,7 @@
1269812719
}
1269912720
},
1270012721
"required": [
12701-
"callId",
12702-
"agentId"
12722+
"callId"
1270312723
]
1270412724
},
1270512725
"CreatePhoneCallOutput": {
@@ -15376,6 +15396,10 @@
1537615396
"key": "value"
1537715397
}
1537815398
},
15399+
"rating": {
15400+
"type": "number",
15401+
"example": 4
15402+
},
1537915403
"attendees": {
1538015404
"type": "array",
1538115405
"items": {
@@ -15524,6 +15548,10 @@
1552415548
"key": "value"
1552515549
}
1552615550
},
15551+
"rating": {
15552+
"type": "number",
15553+
"example": 4
15554+
},
1552715555
"attendees": {
1552815556
"type": "array",
1552915557
"items": {
@@ -15775,6 +15803,10 @@
1577515803
"key": "value"
1577615804
}
1577715805
},
15806+
"rating": {
15807+
"type": "number",
15808+
"example": 4
15809+
},
1577815810
"seatUid": {
1577915811
"type": "string",
1578015812
"example": "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1"
@@ -15910,6 +15942,10 @@
1591015942
"key": "value"
1591115943
}
1591215944
},
15945+
"rating": {
15946+
"type": "number",
15947+
"example": 4
15948+
},
1591315949
"seatUid": {
1591415950
"type": "string",
1591515951
"example": "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1"
@@ -16090,6 +16126,10 @@
1609016126
"key": "value"
1609116127
}
1609216128
},
16129+
"rating": {
16130+
"type": "number",
16131+
"example": 4
16132+
},
1609316133
"attendees": {
1609416134
"type": "array",
1609516135
"items": {
@@ -16220,6 +16260,10 @@
1622016260
"key": "value"
1622116261
}
1622216262
},
16263+
"rating": {
16264+
"type": "number",
16265+
"example": 4
16266+
},
1622316267
"attendees": {
1622416268
"type": "array",
1622516269
"items": {

0 commit comments

Comments
 (0)