Skip to content

Commit 96cd23f

Browse files
committed
Merge branch 'main' of https://github.com/calcom/cal.com into verify-email
2 parents d8e0d47 + c28eb90 commit 96cd23f

794 files changed

Lines changed: 8532 additions & 9689 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/knowledge-base.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,12 @@ dates.map((date) => dayjs.utc(date).add(1, "day").format());
318318
// ✅ Best - Use native Date when possible
319319
dates.map((date) => new Date(date.valueOf() + 24 * 60 * 60 * 1000));
320320
```
321+
322+
## Avoid using Dayjs if you don’t need to be strictly tz aware.
323+
324+
When doing logic like Dayjs.startOf(".."), you can instead use date-fns' `startOfMonth(dateObj)` / `endOfDay(dateObj)`;
325+
When doing logic that depends on Browser locale, use i18n.language (prefer to deconstruct) like: `const { i18n: { language } } = useLocale();`, in combination with built-in Intl.
326+
327+
Note that with Date, you’re dealing with System time, so it’s not suited to everywhere (such as in the Booker, where instead we’ll likely migrate to Temporal) - but in most cases the above are suitable.
328+
329+
The main reason for doing so is that Dayjs uses a useful, but highly risky plugin system, which has led us to create `@calcom/dayjs` - this is heavy however, because it pre-loads ALL plugins, including locale handling. It’s a non-ideal solution to a problem that unfortunately exists due to Dayjs.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ tsconfig.tsbuildinfo
6666
.turbo
6767

6868
# Prisma generated files
69-
packages/prisma/zod/*.ts
69+
packages/prisma/client/*
70+
packages/prisma/zod/**/*.ts
7071
packages/prisma/enums
7172

7273
# Builds

.yarn/versions/cdc88443.yml

Whitespace-only changes.

.yarn/versions/d9b6bedd.yml

Whitespace-only changes.

apps/api/v1/lib/validations/api-key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from "zod";
22

3-
import { _ApiKeyModel as ApiKey } from "@calcom/prisma/zod";
3+
import { ApiKeySchema as ApiKey } from "@calcom/prisma/zod/modelSchema/ApiKeySchema";
44

55
export const apiKeyCreateBodySchema = ApiKey.pick({
66
note: true,

apps/api/v1/lib/validations/attendee.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { z } from "zod";
22

33
import { emailSchema } from "@calcom/lib/emailSchema";
4-
import { _AttendeeModel as Attendee } from "@calcom/prisma/zod";
4+
import { AttendeeSchema } from "@calcom/prisma/zod/modelSchema/AttendeeSchema";
55

66
import { timeZone } from "~/lib/validations/shared/timeZone";
77

8-
export const schemaAttendeeBaseBodyParams = Attendee.pick({
8+
export const schemaAttendeeBaseBodyParams = AttendeeSchema.pick({
99
bookingId: true,
1010
email: true,
1111
name: true,
@@ -31,7 +31,7 @@ const schemaAttendeeEditParams = z
3131
export const schemaAttendeeEditBodyParams = schemaAttendeeBaseBodyParams.merge(schemaAttendeeEditParams);
3232
export const schemaAttendeeCreateBodyParams = schemaAttendeeBaseBodyParams.merge(schemaAttendeeCreateParams);
3333

34-
export const schemaAttendeeReadPublic = Attendee.pick({
34+
export const schemaAttendeeReadPublic = AttendeeSchema.pick({
3535
id: true,
3636
bookingId: true,
3737
name: true,

apps/api/v1/lib/validations/availability.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { z } from "zod";
22

3-
import { _AvailabilityModel as Availability, _ScheduleModel as Schedule } from "@calcom/prisma/zod";
43
import { denullishShape } from "@calcom/prisma/zod-utils";
4+
import { AvailabilitySchema } from "@calcom/prisma/zod/modelSchema/AvailabilitySchema";
5+
import { ScheduleSchema } from "@calcom/prisma/zod/modelSchema/ScheduleSchema";
56

67
export const schemaAvailabilityBaseBodyParams = /** We make all these properties required */ denullishShape(
7-
Availability.pick({
8+
AvailabilitySchema.pick({
89
/** We need to pass the schedule where this availability belongs to */
910
scheduleId: true,
1011
})
1112
);
1213

13-
export const schemaAvailabilityReadPublic = Availability.pick({
14+
export const schemaAvailabilityReadPublic = AvailabilitySchema.pick({
1415
id: true,
1516
startTime: true,
1617
endTime: true,
@@ -19,7 +20,7 @@ export const schemaAvailabilityReadPublic = Availability.pick({
1920
days: true,
2021
// eventTypeId: true /** @deprecated */,
2122
// userId: true /** @deprecated */,
22-
}).merge(z.object({ success: z.boolean().optional(), Schedule: Schedule.partial() }).partial());
23+
}).merge(z.object({ success: z.boolean().optional(), Schedule: ScheduleSchema.partial() }).partial());
2324

2425
const schemaAvailabilityCreateParams = z
2526
.object({
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { _BookingReferenceModel as BookingReference } from "@calcom/prisma/zod";
21
import { denullishShape } from "@calcom/prisma/zod-utils";
2+
import { BookingReferenceSchema } from "@calcom/prisma/zod/modelSchema/BookingReferenceSchema";
33

4-
export const schemaBookingReferenceBaseBodyParams = BookingReference.pick({
4+
export const schemaBookingReferenceBaseBodyParams = BookingReferenceSchema.pick({
55
type: true,
66
bookingId: true,
77
uid: true,
@@ -11,7 +11,7 @@ export const schemaBookingReferenceBaseBodyParams = BookingReference.pick({
1111
deleted: true,
1212
}).partial();
1313

14-
export const schemaBookingReferenceReadPublic = BookingReference.pick({
14+
export const schemaBookingReferenceReadPublic = BookingReferenceSchema.pick({
1515
id: true,
1616
type: true,
1717
bookingId: true,
@@ -22,7 +22,7 @@ export const schemaBookingReferenceReadPublic = BookingReference.pick({
2222
deleted: true,
2323
});
2424

25-
export const schemaBookingCreateBodyParams = BookingReference.omit({ id: true, bookingId: true })
26-
.merge(denullishShape(BookingReference.pick({ bookingId: true })))
25+
export const schemaBookingCreateBodyParams = BookingReferenceSchema.omit({ id: true, bookingId: true })
26+
.merge(denullishShape(BookingReferenceSchema.pick({ bookingId: true })))
2727
.strict();
2828
export const schemaBookingEditBodyParams = schemaBookingCreateBodyParams.partial();

apps/api/v1/lib/validations/booking.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { z } from "zod";
22

3-
import {
4-
_AttendeeModel,
5-
_BookingModel as Booking,
6-
_EventTypeModel,
7-
_PaymentModel,
8-
_TeamModel,
9-
_UserModel,
10-
} from "@calcom/prisma/zod";
3+
import { extendedBookingCreateBody } from "@calcom/features/bookings/lib/bookingCreateBodySchema";
114
import { iso8601 } from "@calcom/prisma/zod-utils";
12-
import { extendedBookingCreateBody } from "@calcom/prisma/zod/custom/booking";
5+
import { AttendeeSchema } from "@calcom/prisma/zod/modelSchema/AttendeeSchema";
6+
import { BookingSchema as Booking } from "@calcom/prisma/zod/modelSchema/BookingSchema";
7+
import { EventTypeSchema } from "@calcom/prisma/zod/modelSchema/EventTypeSchema";
8+
import { PaymentSchema } from "@calcom/prisma/zod/modelSchema/PaymentSchema";
9+
import { TeamSchema } from "@calcom/prisma/zod/modelSchema/TeamSchema";
10+
import { UserSchema } from "@calcom/prisma/zod/modelSchema/UserSchema";
1311

1412
import { schemaQueryUserId } from "./shared/queryUserId";
1513

@@ -72,17 +70,16 @@ export const schemaBookingEditBodyParams = schemaBookingBaseBodyParams
7270
.merge(schemaBookingEditParams)
7371
.omit({ uid: true });
7472

75-
const teamSchema = _TeamModel.pick({
73+
const teamSchema = TeamSchema.pick({
7674
name: true,
7775
slug: true,
7876
});
7977

8078
export const schemaBookingReadPublic = Booking.extend({
81-
eventType: _EventTypeModel
82-
.pick({
83-
title: true,
84-
slug: true,
85-
})
79+
eventType: EventTypeSchema.pick({
80+
title: true,
81+
slug: true,
82+
})
8683
.merge(
8784
z.object({
8885
team: teamSchema.nullish(),
@@ -91,7 +88,7 @@ export const schemaBookingReadPublic = Booking.extend({
9188
.nullish(),
9289
attendees: z
9390
.array(
94-
_AttendeeModel.pick({
91+
AttendeeSchema.pick({
9592
id: true,
9693
email: true,
9794
name: true,
@@ -100,17 +97,15 @@ export const schemaBookingReadPublic = Booking.extend({
10097
})
10198
)
10299
.optional(),
103-
user: _UserModel
104-
.pick({
105-
email: true,
106-
name: true,
107-
timeZone: true,
108-
locale: true,
109-
})
110-
.nullish(),
100+
user: UserSchema.pick({
101+
email: true,
102+
name: true,
103+
timeZone: true,
104+
locale: true,
105+
}).nullish(),
111106
payment: z
112107
.array(
113-
_PaymentModel.pick({
108+
PaymentSchema.pick({
114109
id: true,
115110
success: true,
116111
paymentOption: true,
@@ -140,3 +135,8 @@ export const schemaBookingReadPublic = Booking.extend({
140135
rescheduledBy: true,
141136
createdAt: true,
142137
});
138+
139+
export {
140+
bookingCreateSchemaLegacyPropsForApi,
141+
bookingCreateBodySchemaForApi,
142+
} from "@calcom/features/bookings/lib/bookingCreateBodySchema";

apps/api/v1/lib/validations/destination-calendar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { z } from "zod";
22

3-
import { _DestinationCalendarModel as DestinationCalendar } from "@calcom/prisma/zod";
3+
import { DestinationCalendarSchema } from "@calcom/prisma/zod/modelSchema/DestinationCalendarSchema";
44

5-
export const schemaDestinationCalendarBaseBodyParams = DestinationCalendar.pick({
5+
export const schemaDestinationCalendarBaseBodyParams = DestinationCalendarSchema.pick({
66
integration: true,
77
externalId: true,
88
eventTypeId: true,
@@ -38,7 +38,7 @@ export const schemaDestinationCalendarEditBodyParams = schemaDestinationCalendar
3838
schemaDestinationCalendarEditParams
3939
);
4040

41-
export const schemaDestinationCalendarReadPublic = DestinationCalendar.pick({
41+
export const schemaDestinationCalendarReadPublic = DestinationCalendarSchema.pick({
4242
id: true,
4343
integration: true,
4444
externalId: true,

0 commit comments

Comments
 (0)