feat: v2 bookings return rescheduledToUid (#22289)
This commit is contained in:
1 parent
64305ffee1
commit
94a537bfda
6 files changed
+132
-34
No files matched your search
@@ -1425,8 +1425,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const data: BookingOutput_2024_08_13 = responseBody.data;
|
const data: BookingOutput_2024_08_13 = responseBody.data;
|
||||||
expect(data.status).toEqual("cancelled");
|
expect(data.status).toEqual("cancelled");
|
||||||
|
expect(data.rescheduledToUid).toEqual(rescheduledBooking.uid);
|
||||||
createdBooking = data;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -596,9 +596,9 @@ export class BookingsService_2024_08_13 {
|
|||||||
} else if (isRecurring && isSeated) {
|
} else if (isRecurring && isSeated) {
|
||||||
formattedBookings.push(this.outputService.getOutputRecurringSeatedBooking(formatted));
|
formattedBookings.push(this.outputService.getOutputRecurringSeatedBooking(formatted));
|
||||||
} else if (isSeated) {
|
} else if (isSeated) {
|
||||||
formattedBookings.push(this.outputService.getOutputSeatedBooking(formatted));
|
formattedBookings.push(await this.outputService.getOutputSeatedBooking(formatted));
|
||||||
} else {
|
} 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 {
|
export class OutputBookingsService_2024_08_13 {
|
||||||
constructor(private readonly bookingsRepository: BookingsRepository_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 dateStart = DateTime.fromISO(databaseBooking.startTime.toISOString());
|
||||||
const dateEnd = DateTime.fromISO(databaseBooking.endTime.toISOString());
|
const dateEnd = DateTime.fromISO(databaseBooking.endTime.toISOString());
|
||||||
const duration = dateEnd.diff(dateStart, "minutes").minutes;
|
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 metadata = safeParse(bookingMetadataSchema, databaseBooking.metadata, defaultBookingMetadata);
|
||||||
const location = metadata?.videoCallUrl || databaseBooking.location;
|
const location = metadata?.videoCallUrl || databaseBooking.location;
|
||||||
|
const rescheduledToUid = databaseBooking.rescheduled
|
||||||
|
? await this.getRescheduledToUid(databaseBooking.uid)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const booking = {
|
const booking = {
|
||||||
id: databaseBooking.id,
|
id: databaseBooking.id,
|
||||||
@@ -138,6 +141,7 @@ export class OutputBookingsService_2024_08_13 {
|
|||||||
updatedAt: databaseBooking.updatedAt,
|
updatedAt: databaseBooking.updatedAt,
|
||||||
rating: databaseBooking.rating,
|
rating: databaseBooking.rating,
|
||||||
icsUid: databaseBooking.iCalUID,
|
icsUid: databaseBooking.iCalUID,
|
||||||
|
rescheduledToUid,
|
||||||
};
|
};
|
||||||
|
|
||||||
const bookingTransformed = plainToClass(BookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
|
const bookingTransformed = plainToClass(BookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
|
||||||
@@ -147,6 +151,11 @@ export class OutputBookingsService_2024_08_13 {
|
|||||||
return bookingTransformed;
|
return bookingTransformed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getRescheduledToUid(bookingUid: string) {
|
||||||
|
const rescheduledTo = await this.bookingsRepository.getByFromReschedule(bookingUid);
|
||||||
|
return rescheduledTo?.uid;
|
||||||
|
}
|
||||||
|
|
||||||
getUserDefinedMetadata(databaseMetadata: DatabaseMetadata) {
|
getUserDefinedMetadata(databaseMetadata: DatabaseMetadata) {
|
||||||
if (databaseMetadata === null) return {};
|
if (databaseMetadata === null) return {};
|
||||||
|
|
||||||
@@ -246,20 +255,23 @@ export class OutputBookingsService_2024_08_13 {
|
|||||||
return bookingTransformed;
|
return bookingTransformed;
|
||||||
}
|
}
|
||||||
|
|
||||||
getOutputCreateSeatedBooking(
|
async getOutputCreateSeatedBooking(
|
||||||
databaseBooking: DatabaseBooking,
|
databaseBooking: DatabaseBooking,
|
||||||
seatUid: string
|
seatUid: string
|
||||||
): CreateSeatedBookingOutput_2024_08_13 {
|
): Promise<CreateSeatedBookingOutput_2024_08_13> {
|
||||||
const getSeatedBookingOutput = this.getOutputSeatedBooking(databaseBooking);
|
const getSeatedBookingOutput = await this.getOutputSeatedBooking(databaseBooking);
|
||||||
return { ...getSeatedBookingOutput, seatUid };
|
return { ...getSeatedBookingOutput, seatUid };
|
||||||
}
|
}
|
||||||
|
|
||||||
getOutputSeatedBooking(databaseBooking: DatabaseBooking) {
|
async getOutputSeatedBooking(databaseBooking: DatabaseBooking) {
|
||||||
const dateStart = DateTime.fromISO(databaseBooking.startTime.toISOString());
|
const dateStart = DateTime.fromISO(databaseBooking.startTime.toISOString());
|
||||||
const dateEnd = DateTime.fromISO(databaseBooking.endTime.toISOString());
|
const dateEnd = DateTime.fromISO(databaseBooking.endTime.toISOString());
|
||||||
const duration = dateEnd.diff(dateStart, "minutes").minutes;
|
const duration = dateEnd.diff(dateStart, "minutes").minutes;
|
||||||
const metadata = safeParse(bookingMetadataSchema, databaseBooking.metadata, defaultBookingMetadata);
|
const metadata = safeParse(bookingMetadataSchema, databaseBooking.metadata, defaultBookingMetadata);
|
||||||
const location = metadata?.videoCallUrl || databaseBooking.location;
|
const location = metadata?.videoCallUrl || databaseBooking.location;
|
||||||
|
const rescheduledToUid = databaseBooking.rescheduled
|
||||||
|
? await this.getRescheduledToUid(databaseBooking.uid)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const booking = {
|
const booking = {
|
||||||
id: databaseBooking.id,
|
id: databaseBooking.id,
|
||||||
@@ -286,6 +298,7 @@ export class OutputBookingsService_2024_08_13 {
|
|||||||
updatedAt: databaseBooking.updatedAt,
|
updatedAt: databaseBooking.updatedAt,
|
||||||
rating: databaseBooking.rating,
|
rating: databaseBooking.rating,
|
||||||
icsUid: databaseBooking.iCalUID,
|
icsUid: databaseBooking.iCalUID,
|
||||||
|
rescheduledToUid,
|
||||||
};
|
};
|
||||||
|
|
||||||
const parsed = plainToClass(GetSeatedBookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
|
const parsed = plainToClass(GetSeatedBookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
|
||||||
|
|||||||
@@ -21402,8 +21402,7 @@
|
|||||||
"OOO_CREATED",
|
"OOO_CREATED",
|
||||||
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
||||||
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
||||||
"FORM_SUBMITTED_NO_EVENT",
|
"FORM_SUBMITTED_NO_EVENT"
|
||||||
"RESERVATION_EXPIRED"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
@@ -21480,8 +21479,7 @@
|
|||||||
"OOO_CREATED",
|
"OOO_CREATED",
|
||||||
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
||||||
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
||||||
"FORM_SUBMITTED_NO_EVENT",
|
"FORM_SUBMITTED_NO_EVENT"
|
||||||
"RESERVATION_EXPIRED"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
@@ -24602,7 +24600,8 @@
|
|||||||
"sk",
|
"sk",
|
||||||
"ta",
|
"ta",
|
||||||
"uk",
|
"uk",
|
||||||
"zh-TW"
|
"zh-TW",
|
||||||
|
"bn"
|
||||||
],
|
],
|
||||||
"example": "en"
|
"example": "en"
|
||||||
},
|
},
|
||||||
@@ -24675,7 +24674,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -24832,7 +24837,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -25000,7 +25011,8 @@
|
|||||||
"sk",
|
"sk",
|
||||||
"ta",
|
"ta",
|
||||||
"uk",
|
"uk",
|
||||||
"zh-TW"
|
"zh-TW",
|
||||||
|
"bn"
|
||||||
],
|
],
|
||||||
"example": "en"
|
"example": "en"
|
||||||
},
|
},
|
||||||
@@ -25092,7 +25104,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -25236,7 +25254,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -25425,7 +25449,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -25564,7 +25594,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -19759,8 +19759,7 @@
|
|||||||
"OOO_CREATED",
|
"OOO_CREATED",
|
||||||
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
||||||
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
||||||
"FORM_SUBMITTED_NO_EVENT",
|
"FORM_SUBMITTED_NO_EVENT"
|
||||||
"RESERVATION_EXPIRED"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
@@ -19827,8 +19826,7 @@
|
|||||||
"OOO_CREATED",
|
"OOO_CREATED",
|
||||||
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_HOSTS_CAL_VIDEO_NO_SHOW",
|
||||||
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
"AFTER_GUESTS_CAL_VIDEO_NO_SHOW",
|
||||||
"FORM_SUBMITTED_NO_EVENT",
|
"FORM_SUBMITTED_NO_EVENT"
|
||||||
"RESERVATION_EXPIRED"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
@@ -22538,7 +22536,8 @@
|
|||||||
"sk",
|
"sk",
|
||||||
"ta",
|
"ta",
|
||||||
"uk",
|
"uk",
|
||||||
"zh-TW"
|
"zh-TW",
|
||||||
|
"bn"
|
||||||
],
|
],
|
||||||
"example": "en"
|
"example": "en"
|
||||||
},
|
},
|
||||||
@@ -22601,7 +22600,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -22750,7 +22755,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -22915,7 +22926,8 @@
|
|||||||
"sk",
|
"sk",
|
||||||
"ta",
|
"ta",
|
||||||
"uk",
|
"uk",
|
||||||
"zh-TW"
|
"zh-TW",
|
||||||
|
"bn"
|
||||||
],
|
],
|
||||||
"example": "en"
|
"example": "en"
|
||||||
},
|
},
|
||||||
@@ -22995,7 +23007,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -23134,7 +23152,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -23312,7 +23336,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -23446,7 +23476,13 @@
|
|||||||
},
|
},
|
||||||
"rescheduledFromUid": {
|
"rescheduledFromUid": {
|
||||||
"type": "string",
|
"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": {
|
"start": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -174,12 +174,26 @@ class BaseBookingOutput_2024_08_13 {
|
|||||||
@Expose()
|
@Expose()
|
||||||
rescheduledByEmail?: string;
|
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()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Expose()
|
@Expose()
|
||||||
rescheduledFromUid?: string;
|
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" })
|
@ApiProperty({ type: String, example: "2024-08-13T15:30:00Z" })
|
||||||
@IsDateString()
|
@IsDateString()
|
||||||
@Expose()
|
@Expose()
|
||||||
|
|||||||
Reference in new issue
Block a user