mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
0e3696f20c
* chore: dedupe yarn.lock to remove duplicate package versions - Consolidated 762 duplicate package versions - Reduced yarn.lock from 51,211 lines (1.7MB) to 44,471 lines (1.5MB) - Removed 7,071 lines (~200KB) of redundant dependency entries - Major packages deduplicated include: resolve, semver, type-fest, commander, glob, lru-cache, dotenv, @babel/* packages, typescript, tslib, postcss, and many more Co-Authored-By: [email protected] <[email protected]> * fix: resolve type errors in managed event types and react-select components - Add Zod-compatible versions of allManagedEventTypeProps and unlockedManagedEventTypeProps that only include scalar fields (excludes Prisma relation fields) - Update handleChildrenEventTypes.ts and queries.ts to use the new Zod-compatible props - Fix react-select CSS type errors in Select.tsx files by using Object.assign instead of spread operator to avoid TypeScript type inference issues - Fix lint warning in updateNewTeamMemberEventTypes by using if statement Co-Authored-By: [email protected] <[email protected]> * fix: derive eventType parameter type from actual query result Use Awaited<ReturnType<typeof getEventTypesToAddNewMembers>>[number] to ensure type safety at call sites, avoiding Prisma type namespace mismatches. Co-Authored-By: [email protected] <[email protected]> * fix: disable turbo cache for @calcom/trpc#build to prevent stale type errors Co-Authored-By: [email protected] <[email protected]> * fix: correct field names in API v1 validation schemas - Remove timeZone from booking schema (field doesn't exist on Booking model) - Remove bookingId from destination-calendar schema (field doesn't exist, only booking relation) - Change avatar to avatarUrl in user schema (correct field name) Co-Authored-By: [email protected] <[email protected]> * fix: use Object.assign for react-select styles to fix TypeScript spread type errors The spread operator causes TypeScript to compute an incompatible type with CSSObjectWithLabel due to the accentColor property. Using Object.assign preserves the correct type inference. Fixed files: - FormEdit.tsx - DestinationCalendarSelector.tsx (features and platform) - TimezoneSelect.tsx - ApiKeyDialogForm.tsx - Select.tsx (features/form) - WebhookForm.tsx Also fixed pre-existing lint warnings: - Constant truthiness in label assignment - Unused variant parameter Co-Authored-By: [email protected] <[email protected]> * fix: remove extra fields from allManagedEventTypePropsForZod to match original behavior The Zod-compatible version should only include scalar fields that were in the original allManagedEventTypeProps. Removed instantMeetingScheduleId, profileId, rrSegmentQueryValue, and assignRRMembersUsingSegment which were incorrectly added and caused test failures by including extra fields in Prisma update payloads. Co-Authored-By: [email protected] <[email protected]> * fix: remove access to fields not in Zod schema - Remove unnecessary destructuring of profileId and instantMeetingScheduleId from managedEventTypeValues in handleChildrenEventTypes.ts (these fields are already sourced from other variables) - Set rrSegmentQueryValue to undefined directly in queries.ts instead of accessing it from managedEventTypeValues (not applicable for managed children) Co-Authored-By: [email protected] <[email protected]> * fix: add name property to mock credentials and revert turbo cache change - Add name property to MockCredential type and factory function in InstallAppButtonChild.test.tsx to match expected credentials type - Revert turbo cache disable for @calcom/trpc#build (per review comment) Co-Authored-By: [email protected] <[email protected]> * fix: revert API v1 validation changes and restore eslint comment - Revert API v1 validation changes (booking.ts, destination-calendar.ts, user.ts) since API v1 is deprecated and these could be breaking changes - Restore eslint-disable comment for @typescript-eslint/no-empty-function in Select.tsx that was accidentally removed Co-Authored-By: [email protected] <[email protected]> * fix: add inputs to @calcom/trpc#build to properly invalidate cache Co-Authored-By: [email protected] <[email protected]> * fix: properly fix API v1 validation schemas for stricter zod 3.25.76 The yarn dedupe upgraded zod from 3.22.4 to 3.25.76, which has stricter .pick() typing that now properly rejects picking non-existent fields. Changes: - user.ts: Pick avatarUrl (actual Prisma field) and extend with avatar for API v1 backward compatibility - booking.ts: Remove timeZone from pick (not a field on Booking model, only exists in nested attendees/user objects) - destination-calendar.ts: Remove bookingId from pick (not a field on DestinationCalendar model) Co-Authored-By: [email protected] <[email protected]> * fix: remove turbo.json inputs for @calcom/trpc#build to use cached artifacts Co-Authored-By: [email protected] <[email protected]> * fix: use robust selector for react-select option in routing forms E2E test The previous selector used .nth(1) which assumed the email text appeared exactly twice in the DOM in a specific order. This broke when react-select was upgraded from 5.7.2 to 5.8.0 via yarn dedupe. The new approach waits for the react-select listbox to appear and clicks the option within it, which is more robust against DOM structure changes. Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
149 lines
4.2 KiB
TypeScript
149 lines
4.2 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { extendedBookingCreateBody } from "@calcom/features/bookings/lib/bookingCreateBodySchema";
|
|
import { iso8601 } from "@calcom/prisma/zod-utils";
|
|
import { AttendeeSchema } from "@calcom/prisma/zod/modelSchema/AttendeeSchema";
|
|
import { BookingSchema as Booking } from "@calcom/prisma/zod/modelSchema/BookingSchema";
|
|
import { EventTypeSchema } from "@calcom/prisma/zod/modelSchema/EventTypeSchema";
|
|
import { PaymentSchema } from "@calcom/prisma/zod/modelSchema/PaymentSchema";
|
|
import { TeamSchema } from "@calcom/prisma/zod/modelSchema/TeamSchema";
|
|
import { UserSchema } from "@calcom/prisma/zod/modelSchema/UserSchema";
|
|
|
|
import { schemaQueryUserId } from "./shared/queryUserId";
|
|
|
|
const schemaBookingBaseBodyParams = Booking.pick({
|
|
uid: true,
|
|
userId: true,
|
|
eventTypeId: true,
|
|
title: true,
|
|
description: true,
|
|
startTime: true,
|
|
endTime: true,
|
|
status: true,
|
|
rescheduledBy: true,
|
|
cancelledBy: true,
|
|
createdAt: true,
|
|
}).partial();
|
|
|
|
export const schemaBookingCreateBodyParams = extendedBookingCreateBody.merge(schemaQueryUserId.partial());
|
|
|
|
export const schemaBookingGetParams = z.object({
|
|
dateFrom: iso8601.optional(),
|
|
dateTo: iso8601.optional(),
|
|
order: z.enum(["asc", "desc"]).default("asc"),
|
|
sortBy: z.enum(["createdAt", "updatedAt"]).optional(),
|
|
status: z.enum(["upcoming"]).optional(),
|
|
});
|
|
|
|
export type Status = z.infer<typeof schemaBookingGetParams>["status"];
|
|
|
|
export const bookingCancelSchema = z.object({
|
|
id: z.number(),
|
|
allRemainingBookings: z.boolean().optional(),
|
|
cancelSubsequentBookings: z.boolean().optional(),
|
|
cancellationReason: z.string().optional().default("Not Provided"),
|
|
seatReferenceUid: z.string().optional(),
|
|
cancelledBy: z.string().email({ message: "Invalid email" }).optional(),
|
|
internalNote: z
|
|
.object({
|
|
id: z.number(),
|
|
name: z.string(),
|
|
cancellationReason: z.string().optional().nullable(),
|
|
})
|
|
.optional()
|
|
.nullable(),
|
|
});
|
|
|
|
const schemaBookingEditParams = z
|
|
.object({
|
|
title: z.string().optional(),
|
|
startTime: iso8601.optional(),
|
|
endTime: iso8601.optional(),
|
|
cancelledBy: z.string().email({ message: "Invalid Email" }).optional(),
|
|
rescheduledBy: z.string().email({ message: "Invalid Email" }).optional(),
|
|
// Not supporting responses in edit as that might require re-triggering emails
|
|
// responses
|
|
})
|
|
.strict();
|
|
|
|
export const schemaBookingEditBodyParams = schemaBookingBaseBodyParams
|
|
.merge(schemaBookingEditParams)
|
|
.omit({ uid: true });
|
|
|
|
const teamSchema = TeamSchema.pick({
|
|
name: true,
|
|
slug: true,
|
|
});
|
|
|
|
export const schemaBookingReadPublic = Booking.extend({
|
|
eventType: EventTypeSchema.pick({
|
|
title: true,
|
|
slug: true,
|
|
})
|
|
.merge(
|
|
z.object({
|
|
team: teamSchema.nullish(),
|
|
})
|
|
)
|
|
.nullish(),
|
|
attendees: z
|
|
.array(
|
|
AttendeeSchema.pick({
|
|
id: true,
|
|
email: true,
|
|
name: true,
|
|
timeZone: true,
|
|
locale: true,
|
|
})
|
|
)
|
|
.optional(),
|
|
user: UserSchema.pick({
|
|
email: true,
|
|
name: true,
|
|
timeZone: true,
|
|
locale: true,
|
|
}).nullish(),
|
|
payment: z
|
|
.array(
|
|
PaymentSchema.pick({
|
|
id: true,
|
|
success: true,
|
|
paymentOption: true,
|
|
})
|
|
)
|
|
.optional(),
|
|
responses: z.record(z.any()).nullable(),
|
|
// Override metadata to handle reassignment objects from Round Robin/Managed Events
|
|
// Safe to use z.any() here because:
|
|
// 1. API v1 POST only accepts z.record(z.string()) for metadata (user input restricted)
|
|
// 2. API v1 PATCH does not accept metadata changes at all
|
|
// 3. Complex metadata (objects) are only set by trusted internal features
|
|
metadata: z.record(z.any()).nullable(),
|
|
}).pick({
|
|
id: true,
|
|
userId: true,
|
|
description: true,
|
|
eventTypeId: true,
|
|
uid: true,
|
|
title: true,
|
|
startTime: true,
|
|
endTime: true,
|
|
// Note: timeZone is not a field on Booking model - it's in nested attendees/user objects
|
|
attendees: true,
|
|
user: true,
|
|
eventType: true,
|
|
payment: true,
|
|
metadata: true,
|
|
status: true,
|
|
responses: true,
|
|
fromReschedule: true,
|
|
cancelledBy: true,
|
|
rescheduledBy: true,
|
|
createdAt: true,
|
|
});
|
|
|
|
export {
|
|
bookingCreateSchemaLegacyPropsForApi,
|
|
bookingCreateBodySchemaForApi,
|
|
} from "@calcom/features/bookings/lib/bookingCreateBodySchema";
|