hunk.code_window:     where: { id: teamId, members: { some: { userId, role: { in: ["OWNER", "ADMIN"] } } } },
     });
     if (!_team) throw new HttpError({ statusCode: 401, message: "Unauthorized: OWNER or ADMIN required" });
     const team = await prisma.team.update({ where: { id: teamId }, data });
     return { team: schemaTeamReadPublic.parse(team) };
   }
   export default defaultResponder(patchHandler);
hunk.labels: keep keep keep replace keep keep keep keep
hunk.after_edit:   // TODO: Perhaps there is a better fix for this?
     const cloneData: typeof data & {
       metadata: NonNullable<typeof data.metadata> | undefined;
     } = {
       ...data,
       metadata: data.metadata === null ? {} : data.metadata || undefined,
     };
     const team = await prisma.team.update({ where: { id: teamId }, data: cloneData });
  
hunk.file_path: pages/api/teams/[teamId]/_patch.ts
hunk.type: replace
file: import { z } from "zod";
  
  import { _DestinationCalendarModel as DestinationCalendar } from "@calcom/prisma/zod";
  
  export const schemaDestinationCalendarBaseBodyParams = DestinationCalendar.pick({
    integration: true,
    externalId: true,
    eventTypeId: true,
    bookingId: true,
    userId: true,
  }).partial();
  
  const schemaDestinationCalendarCreateParams = z
    .object({
      integration: z.string(),
      externalId: z.string(),
      eventTypeId: z.number(),
      bookingId: z.number(),
      userId: z.number(),
    })
    .strict();
  
  export const schemaDestinationCalendarCreateBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
    schemaDestinationCalendarCreateParams
  );
  
  const schemaDestinationCalendarEditParams = z
    .object({
      integration: z.string().optional(),
      externalId: z.string().optional(),
      eventTypeId: z.number().optional(),
      bookingId: z.number().optional(),
      userId: z.number().optional(),
    })
    .strict();
  
  export const schemaDestinationCalendarEditBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
    schemaDestinationCalendarEditParams
  );
  
  export const schemaDestinationCalendarReadPublic = DestinationCalendar.pick({
    id: true,
    integration: true,
    externalId: true,
    eventTypeId: true,
    bookingId: true,
    userId: true,
  });
  