Skip to content

Scheduling infrastructure for absolutely everyone.

fix: omit metadata/locations and rewrite as json

Agusti Fernandez Pardo37069e2d7b4d
diff --git a/lib/types.ts b/lib/types.ts
index 58d4b17a9c9..574e164e29b 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -124,17 +124,17 @@ export type EventTypeCustomInputResponse = BaseResponse & {
export type EventTypeCustomInputsResponse = BaseResponse & {
event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
};
-export type EventTypeWithMetadataLocations = EventType & {
- locations?: object;
- metadata?: object;
- recurringEvent?: object;
-};
+export interface EventTypeMeta extends Omit<EventType, "locations" | "metadata" | "recurringEvent"> {
+ locations?: JSON;
+ metadata?: JSON;
+ recurringEvent: JSON;
+}
// EventType
export type EventTypeResponse = BaseResponse & {
- event_type?: Partial<EventTypeWithMetadataLocations>;
+ event_type?: Partial<EventTypeMeta>;
};
export type EventTypesResponse = BaseResponse & {
- event_types?: Partial<EventTypeWithMetadataLocations>[];
+ event_types?: Partial<EventTypeMeta>[];
};
// Payment
diff --git a/lib/validations/event-type.ts b/lib/validations/event-type.ts
index 2eb3d887749..6b43a4474ae 100644
--- a/lib/validations/event-type.ts
+++ b/lib/validations/event-type.ts
@@ -38,8 +38,8 @@ const schemaEventTypeCreateParams = z
slug: z.string(),
description: z.string().optional().nullable(),
length: z.number().int(),
- // locations: jsonSchema.optional().nullable().or(z.null()),
- // metadata: z.any().optional().nullable().or(z.null()),
+ locations: jsonSchema.optional().nullable().or(z.null()),
+ metadata: z.any().optional().nullable().or(z.null()),
recurringEvent: jsonSchema.optional().nullable().or(z.null()),
})
.strict();
@@ -85,4 +85,6 @@ export const schemaEventTypeReadPublic = EventType.pick({
slotInterval: true,
successRedirectUrl: true,
description: true,
+ locations: true,
+ metadata: true,
});
diff --git a/pages/api/event-types/[id].ts b/pages/api/event-types/[id].ts
index 19ca5e0cbbd..6319b48b9e2 100644
--- a/pages/api/event-types/[id].ts
+++ b/pages/api/event-types/[id].ts
@@ -55,7 +55,7 @@ export async function eventTypeById(
case "GET":
await prisma.eventType
.findUnique({ where: { id: safeQuery.data.id } })
- // .then((data) => schemaEventTypeReadPublic.parse(data))
+ .then((data) => schemaEventTypeReadPublic.parse(data))
.then((event_type) => res.status(200).json({ event_type }))
.catch((error: Error) =>
res.status(404).json({
diff --git a/pages/api/event-types/index.ts b/pages/api/event-types/index.ts
index 4570934b177..163fa501fb4 100644
--- a/pages/api/event-types/index.ts
+++ b/pages/api/event-types/index.ts
@@ -30,8 +30,8 @@ async function createOrlistAllEventTypes(
* description: No event types were found
*/
const data = await prisma.eventType.findMany({ where: { userId } });
- // const event_types = data.map((eventType) => schemaEventTypeReadPublic.parse(eventType));
- if (data) res.status(200).json({ event_types: data });
+ const event_types = data.map((eventType) => schemaEventTypeReadPublic.parse(eventType));
+ if (event_types) res.status(200).json({ event_types });
else
(error: Error) =>
res.status(404).json({