feat: v2 bookings return rescheduledToUid (#22289)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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" });
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user