Skip to content

Scheduling infrastructure for absolutely everyone.

feat: v2 bookings return rescheduledToUid (#22289)

Lauris Skraucis94a537bfda96
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts
index 266eafca184..9f5a23ac52e 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts
@@ -1425,8 +1425,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
// @ts-ignore
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.status).toEqual("cancelled");
-
- createdBooking = data;
+ expect(data.rescheduledToUid).toEqual(rescheduledBooking.uid);
});
});
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
index ce26ba6b623..6ec04b417a8 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
@@ -596,9 +596,9 @@ export class BookingsService_2024_08_13 {
} else if (isRecurring && isSeated) {
formattedBookings.push(this.outputService.getOutputRecurringSeatedBooking(formatted));
} else if (isSeated) {
- formattedBookings.push(this.outputService.getOutputSeatedBooking(formatted));
+ formattedBookings.push(await this.outputService.getOutputSeatedBooking(formatted));
} else {
- formattedBookings.push(this.outputService.getOutputBooking(formatted));
+ formattedBookings.push(await this.outputService.getOutputBooking(formatted));
}
}
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts b/apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts
index 72f36a2cae5..c22f0081ce9 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts
@@ -90,7 +90,7 @@ type DatabaseMetadata = z.infer<typeof bookingMetadataSchema>;
export class OutputBookingsService_2024_08_13 {
constructor(private readonly bookingsRepository: BookingsRepository_2024_08_13) {}
- getOutputBooking(databaseBooking: DatabaseBooking) {
+ async getOutputBooking(databaseBooking: DatabaseBooking) {
const dateStart = DateTime.fromISO(databaseBooking.startTime.toISOString());
const dateEnd = DateTime.fromISO(databaseBooking.endTime.toISOString());
const duration = dateEnd.diff(dateStart, "minutes").minutes;
@@ -101,6 +101,9 @@ export class OutputBookingsService_2024_08_13 {
);
const metadata = safeParse(bookingMetadataSchema, databaseBooking.metadata, defaultBookingMetadata);
const location = metadata?.videoCallUrl || databaseBooking.location;
+ const rescheduledToUid = databaseBooking.rescheduled
+ ? await this.getRescheduledToUid(databaseBooking.uid)
+ : undefined;
const booking = {
id: databaseBooking.id,
@@ -138,6 +141,7 @@ export class OutputBookingsService_2024_08_13 {
updatedAt: databaseBooking.updatedAt,
rating: databaseBooking.rating,
icsUid: databaseBooking.iCalUID,
+ rescheduledToUid,
};
const bookingTransformed = plainToClass(BookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
@@ -147,6 +151,11 @@ export class OutputBookingsService_2024_08_13 {
return bookingTransformed;
}
+ async getRescheduledToUid(bookingUid: string) {
+ const rescheduledTo = await this.bookingsRepository.getByFromReschedule(bookingUid);
+ return rescheduledTo?.uid;
+ }
+
getUserDefinedMetadata(databaseMetadata: DatabaseMetadata) {
if (databaseMetadata === null) return {};
@@ -246,20 +255,23 @@ export class OutputBookingsService_2024_08_13 {
return bookingTransformed;
}
- getOutputCreateSeatedBooking(
+ async getOutputCreateSeatedBooking(
databaseBooking: DatabaseBooking,
seatUid: string
- ): CreateSeatedBookingOutput_2024_08_13 {
- const getSeatedBookingOutput = this.getOutputSeatedBooking(databaseBooking);
+ ): Promise<CreateSeatedBookingOutput_2024_08_13> {
+ const getSeatedBookingOutput = await this.getOutputSeatedBooking(databaseBooking);
return { ...getSeatedBookingOutput, seatUid };
}
- getOutputSeatedBooking(databaseBooking: DatabaseBooking) {
+ async getOutputSeatedBooking(databaseBooking: DatabaseBooking) {
const dateStart = DateTime.fromISO(databaseBooking.startTime.toISOString());
const dateEnd = DateTime.fromISO(databaseBooking.endTime.toISOString());
const duration = dateEnd.diff(dateStart, "minutes").minutes;
const metadata = safeParse(bookingMetadataSchema, databaseBooking.metadata, defaultBookingMetadata);
const location = metadata?.videoCallUrl || databaseBooking.location;
+ const rescheduledToUid = databaseBooking.rescheduled
+ ? await this.getRescheduledToUid(databaseBooking.uid)
+ : undefined;
const booking = {
id: databaseBooking.id,
@@ -286,6 +298,7 @@ export class OutputBookingsService_2024_08_13 {
updatedAt: databaseBooking.updatedAt,
rating: databaseBooking.rating,
icsUid: databaseBooking.iCalUID,
+ rescheduledToUid,
};
const parsed = plainToClass(GetSeatedBookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.json
index 2079cca58e4..4c8e941a647 100644
--- a/apps/api/v2/swagger/documentation.json
+++ b/apps/api/v2/swagger/documentation.json
@@ -21402,8 +21402,7 @@
"OOO_CREATED",
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
- "FORM_SUBMITTED_NO_EVENT",
- "RESERVATION_EXPIRED"
+ "FORM_SUBMITTED_NO_EVENT"
]
},
"secret": {
@@ -21480,8 +21479,7 @@
"OOO_CREATED",
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
- "FORM_SUBMITTED_NO_EVENT",
- "RESERVATION_EXPIRED"
+ "FORM_SUBMITTED_NO_EVENT"
]
},
"secret": {
@@ -24602,7 +24600,8 @@
"sk",
"ta",
"uk",
- "zh-TW"
+ "zh-TW",
+ "bn"
],
"example": "en"
},
@@ -24675,7 +24674,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -24832,7 +24837,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -25000,7 +25011,8 @@
"sk",
"ta",
"uk",
- "zh-TW"
+ "zh-TW",
+ "bn"
],
"example": "en"
},
@@ -25092,7 +25104,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -25236,7 +25254,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -25425,7 +25449,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -25564,7 +25594,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
diff --git a/docs/api-reference/v2/openapi.json b/docs/api-reference/v2/openapi.json
index 258e8fb21d1..5ab2292de79 100644
--- a/docs/api-reference/v2/openapi.json
+++ b/docs/api-reference/v2/openapi.json
@@ -19759,8 +19759,7 @@
"OOO_CREATED",
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
- "FORM_SUBMITTED_NO_EVENT",
- "RESERVATION_EXPIRED"
+ "FORM_SUBMITTED_NO_EVENT"
]
},
"secret": {
@@ -19827,8 +19826,7 @@
"OOO_CREATED",
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
- "FORM_SUBMITTED_NO_EVENT",
- "RESERVATION_EXPIRED"
+ "FORM_SUBMITTED_NO_EVENT"
]
},
"secret": {
@@ -22538,7 +22536,8 @@
"sk",
"ta",
"uk",
- "zh-TW"
+ "zh-TW",
+ "bn"
],
"example": "en"
},
@@ -22601,7 +22600,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -22750,7 +22755,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -22915,7 +22926,8 @@
"sk",
"ta",
"uk",
- "zh-TW"
+ "zh-TW",
+ "bn"
],
"example": "en"
},
@@ -22995,7 +23007,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -23134,7 +23152,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -23312,7 +23336,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
@@ -23446,7 +23476,13 @@
},
"rescheduledFromUid": {
"type": "string",
- "example": "previous_uid_123"
+ "example": "previous_uid_123",
+ "description": "UID of the previous booking from which this booking was rescheduled."
+ },
+ "rescheduledToUid": {
+ "type": "string",
+ "example": "new_uid_456",
+ "description": "UID of the new booking to which this booking was rescheduled."
},
"start": {
"type": "string",
diff --git a/packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts b/packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts
index 3d6aefbcf69..103478aaa7d 100644
--- a/packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts
+++ b/packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts
@@ -174,12 +174,26 @@ class BaseBookingOutput_2024_08_13 {
@Expose()
rescheduledByEmail?: string;
- @ApiPropertyOptional({ type: String, example: "previous_uid_123" })
+ @ApiPropertyOptional({
+ type: String,
+ example: "previous_uid_123",
+ description: "UID of the previous booking from which this booking was rescheduled.",
+ })
@IsString()
@IsOptional()
@Expose()
rescheduledFromUid?: string;
+ @ApiPropertyOptional({
+ type: String,
+ example: "new_uid_456",
+ description: "UID of the new booking to which this booking was rescheduled.",
+ })
+ @IsString()
+ @IsOptional()
+ @Expose()
+ rescheduledToUid?: string;
+
@ApiProperty({ type: String, example: "2024-08-13T15:30:00Z" })
@IsDateString()
@Expose()