Skip to content

Commit c28eb90

Browse files
zomarsemrysaljoeauyeungsupalarryThyMinimalDev
authored
chore: Upgrade prisma to 6.7.0 (calcom#21264)
* chore: Upgrade prisma to 6.7.0 * Build fixes * type fixes Signed-off-by: Omar López <zomars@me.com> * Update schema.prisma * Patching * Revert "Update schema.prisma" This reverts commit 47d8618. * Revert "Patching" This reverts commit a1d2e30. * Revert schema changes Signed-off-by: Omar López <zomars@me.com> * WIP Signed-off-by: Omar López <zomars@me.com> * Update getPublicEvent.ts * Update imports Signed-off-by: Omar López <zomars@me.com> * Update gitignore Signed-off-by: Omar López <zomars@me.com> * update remaining imports Signed-off-by: Omar López <zomars@me.com> * Delete .cursor/config.json * Discard changes to packages/features/eventtypes/lib/getPublicEvent.ts * Update _get.ts * Update user.ts * Update .gitignore * update * Update WorkflowStepContainer.tsx * Update next-auth-custom-adapter.ts * Update getPublicEvent.ts * Update workflow.ts * Update next-auth-custom-adapter.ts * Update next-auth-options.ts * Update bookingScenario.ts * fix missing imports * upgrades prismock Signed-off-by: Omar López <zomars@me.com> * patches prismock Signed-off-by: Omar López <zomars@me.com> * Update reschedule.test.ts * Update prisma.ts * patch prismock Signed-off-by: Omar López <zomars@me.com> * fix enums imports Signed-off-by: Omar López <zomars@me.com> * Revert "Update prisma.ts" This reverts commit 64edcf8. * Revert "patch prismock" This reverts commit e958191. * fix patch * Fix test that overrun the boundary, it shouldn't test too much * Move prisma import to changeSMSLockState * Bring back broken test without illegal imports * Merge with main and fix filter hosts by same round robin host * Fixed buildDryRunBooking fn tests * Fix and move ooo create or update handler test * Fix packages/features/eventtypes/lib/isCurrentlyAvailable.test.ts * Fix packages/trpc/server/routers/viewer/organizations/listMembers.handler.test.ts * Mock @calcom/prisma * Fix: verify-email.test.ts * fix: Moved WebhookService test and fixed default import mock * Fix: Added missing prisma mock, handleNewBooking uses that of course * We're not testing createContext here * fix: Prisma mock fix for listMembers.test.ts * More fixes to broken testcases * Forgot to remove borked test * Prevent the need to mock a lot of dependencies by moving out buildBaseWhereCondition to its own file * Temporarily skip getCalendarEvents, needs a rewrite * Fix: turns out you can access protected in testcases * fix further mocks * Added packages/features/insights/server/buildBaseWhereCondition.ts, types * Always great to have a mock and then not use it * And one less again. * fix: confirm.handler.test, didn't mock prisma * fix: Address minor nit by @eunjae & fix ImpersonationProvider test * Updated isPrismaAvailableCheck that doesn't crash on import * fix: Get Prisma directly from the client, it usually involves the Validator and does not need 'local' inclusion * Add zod-prisma-types without the generator enabled (commented out) * Uncomment and see what happens * Change method of import as imports did not work in Input Schemas * Remove custom 'zod' booking model, it does not belong with Prisma * Fix all other global Model imports * Rewrite most schema includes AND remove barrel file * Add bookingCreateBodySchema to features/bookings * Flurry of type fixes for compatibility with new zod gen * Refactor out the custom prisma type createEventTypeInput * Work around nullable eventTypeLocations * HandlePayment type fix * More fixes, final fix remaining is CompleteEventType * Should fix a bunch more booking related type errors * Missed one * Some props missing from BookingCreateBodySchema * Fix location type in handleChildrenEventTypes * Little bit hacky imo but it works * Final type error \o/ * Forgot to include Prisma * Do not include zod-utils in booker/types * Oops, was already including Booker/types * Fix membership type, also disallow updating createdAt/updatedAt, make part of patch/post * Fix api v1 type errors * Fix EventTypeDescription typings * Remove getParserWithGeneric, use userBodySchema with UserSchema * use centralized timeZoneSchema * Implement feedback by @zomars * Couple of WIP pushes * Fix tests * Type fixes in `handleChildrenEventTypes` test * Try and parse metadata before use * Change zod-prisma-types configuration for optimal performance * Fix prisma validator error in `prisma/selects/credential` * Disable seperate relations model, hits a bug * Import absolute - this makes rollup work in @platform/libraries * Attempt at removing resolutions override * Refactor using `Prisma.validator` to `satisfies` * Build atoms using @calcom/prisma/client * Build atoms using @calcom/prisma/client * fixes * Update eventTypeSelect.ts * Adjust `eventTypeMetaDataSchemaWithUntypedApps` from `unknown` to `record(any)` * `EventTypeDescription` rely on `descriptionAsSafeHTML` instead of `description` * Add `seatsPerTimeSlot` to event type public select * Fix typing in `users-public-view` getServerSide props * Add missing `schedulingType` to prop * chore: bump platform libraries * Function return type is illegal, not sure how this passed eslint (calcom#21567) * Merged with main * Update updateTokenObject.ts * Update handleResponse.ts * Update index.ts * Update handleChildrenEventTypes.ts * Update booking-idempotency-key.ts * Update WebhookService.test.ts * Update events.test.ts * Update queued-response.test.ts * Update events.test.ts * Update getRoutedUrl.test.ts * fix: type checks Signed-off-by: Omar López <zomars@me.com> * fixes Signed-off-by: Omar López <zomars@me.com> * chore: bump platform libraries * Update yarn.lock * more fixes Signed-off-by: Omar López <zomars@me.com> * fixes Signed-off-by: Omar López <zomars@me.com> * biuld fixes * chore: bump platform libraries * Update conferencing.repository.ts * Update conferencing.repository.ts * Update getCalendarsEvents.test.ts * Update vite.config.js * chore: bump platform libraries * Update users.ts * Discard changes to docs/api-reference/v2/openapi.json * Update vite.config.ts * updated platform libraries * Update get.handler.test.ts * Update get.handler.test.ts * Update schema.prisma * Discard changes to docs/api-reference/v2/openapi.json * Update next-auth-custom-adapter.ts * Update team.ts * Flurry of type fixes * Fix majority of insight related type errors * Type fixes for unlink of account * Make user nullable again * Fixed a bunch of unit tests and one type error * Attempted mock fix * Attempted fix for Attribute type * Ensure default import becomes prisma, but not direct usage * Import default as prisma in prisma.module * Add attributeOption to attribute type * Fix calcom/prisma mock * Refactor Prisma client imports to @calcom/prisma/client Updated all imports from '@prisma/client' to '@calcom/prisma/client' across tests and repository files for consistency and to use the correct Prisma client package. This change improves maintainability and ensures the correct client is referenced throughout the codebase. * Undo removal of max-warnings=0 to get main to merge * Remove unit tests for e2e fixtures, provide new prisma mock * Mock @calcom/prisma in event manager * Mock @calcom/prisma in event manager * Add correct format even with --no-verify * Mock prisma in CalendarManager * Add mock for permission-check.service * Better injection in PrismaApiKeyRepository imports * More mock fixes :) * Fix listMembers.handler.test * Fix User import * Appropriately adjust all types to be imported as types, there were a lot of types imported as normal deps * Why was this a thing? * Strictly speaking; Not using prismock anymore * Ditched patch file for prismock * Fix output.service.ts platform type imports, need concrete for plainToClass * Better typing and tests for unlinkConnectedAccount.handler * Small type fix * Disable calendar cache tests as they are dependent on prismock * chore: bump platform lib * getRoutedUrl test remove of unused import * Extract select to external const on getEventTypesFromDB * Direct select of userSelect from selects/user * fix type error from merging 23653 * Fixed integration tests by removing hardcoded values that were possible due to mocking, but as its now directly hitting the db no longer * fix: vite config atoms prisma client type location * revert: example app prisma client * revert: example app prisma client * bump platform libs * fix: use class instead of type for DI of PlatformBookingsService * update platform libs * remove unused variable * chore: generate prisma client for api v2 * fix: api v2 e2e * fix: atoms e2e * fix: atoms e2e * fix: atoms e2e * fix: api v2 e2e * fix: tsconfig apiv2 enums * publish libraries * Simplify check for existence teamId --------- Signed-off-by: Omar López <zomars@me.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: supalarry <laurisskraucis@gmail.com> Co-authored-by: cal.com <morgan@cal.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: Benny Joo <sldisek783@gmail.com>
1 parent a55d56f commit c28eb90

623 files changed

Lines changed: 4317 additions & 12513 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.

.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

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,

apps/api/v1/lib/validations/event-type-custom-input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { _EventTypeCustomInputModel as EventTypeCustomInput } from "@calcom/prisma/zod";
1+
import { EventTypeCustomInputSchema } from "@calcom/prisma/zod/modelSchema/EventTypeCustomInputSchema";
22

3-
export const schemaEventTypeCustomInputBaseBodyParams = EventTypeCustomInput.omit({
3+
export const schemaEventTypeCustomInputBaseBodyParams = EventTypeCustomInputSchema.omit({
44
id: true,
55
});
66

7-
export const schemaEventTypeCustomInputPublic = EventTypeCustomInput.omit({});
7+
export const schemaEventTypeCustomInputPublic = EventTypeCustomInputSchema.omit({});
88

99
export const schemaEventTypeCustomInputBodyParams = schemaEventTypeCustomInputBaseBodyParams.strict();
1010

apps/api/v1/lib/validations/event-type.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import {
66
MIN_EVENT_DURATION_MINUTES,
77
} from "@calcom/lib/constants";
88
import slugify from "@calcom/lib/slugify";
9-
import { _EventTypeModel as EventType, _HostModel } from "@calcom/prisma/zod";
109
import { customInputSchema, eventTypeBookingFields } from "@calcom/prisma/zod-utils";
10+
import { EventTypeSchema } from "@calcom/prisma/zod/modelSchema/EventTypeSchema";
11+
import { HostSchema } from "@calcom/prisma/zod/modelSchema/HostSchema";
1112

1213
import { Frequency } from "~/lib/types";
1314

@@ -24,7 +25,7 @@ const recurringEventInputSchema = z.object({
2425
tzid: timeZone.optional(),
2526
});
2627

27-
const hostSchema = _HostModel.pick({
28+
const hostSchema = HostSchema.pick({
2829
isFixed: true,
2930
userId: true,
3031
scheduleId: true,
@@ -35,7 +36,7 @@ export const childrenSchema = z.object({
3536
userId: z.number().int(),
3637
});
3738

38-
export const schemaEventTypeBaseBodyParams = EventType.pick({
39+
export const schemaEventTypeBaseBodyParams = EventTypeSchema.pick({
3940
title: true,
4041
description: true,
4142
slug: true,
@@ -117,7 +118,7 @@ const schemaEventTypeEditParams = z
117118
.strict();
118119

119120
export const schemaEventTypeEditBodyParams = schemaEventTypeBaseBodyParams.merge(schemaEventTypeEditParams);
120-
export const schemaEventTypeReadPublic = EventType.pick({
121+
export const schemaEventTypeReadPublic = EventTypeSchema.pick({
121122
id: true,
122123
title: true,
123124
slug: true,

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

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

33
import { MembershipRole } from "@calcom/prisma/enums";
4-
import { _MembershipModel as Membership, _TeamModel } from "@calcom/prisma/zod";
54
import { stringOrNumber } from "@calcom/prisma/zod-utils";
5+
import { MembershipSchema } from "@calcom/prisma/zod/modelSchema/MembershipSchema";
6+
import { TeamSchema } from "@calcom/prisma/zod/modelSchema/TeamSchema";
67

78
import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString";
89
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
910

10-
export const schemaMembershipBaseBodyParams = Membership.omit({});
11+
export const schemaMembershipBaseBodyParams = MembershipSchema.omit({});
1112

1213
const schemaMembershipRequiredParams = z.object({
1314
teamId: z.number(),
1415
});
1516

16-
export const membershipCreateBodySchema = Membership.omit({ id: true })
17+
export const membershipCreateBodySchema = MembershipSchema.omit({
18+
id: true,
19+
createdAt: true,
20+
updatedAt: true,
21+
})
1722
.partial({
1823
accepted: true,
1924
role: true,
@@ -26,11 +31,13 @@ export const membershipCreateBodySchema = Membership.omit({ id: true })
2631
...v,
2732
}));
2833

29-
export const membershipEditBodySchema = Membership.omit({
34+
export const membershipEditBodySchema = MembershipSchema.omit({
3035
/** To avoid complication, let's avoid updating these, instead you can delete and create a new invite */
3136
teamId: true,
3237
userId: true,
3338
id: true,
39+
createdAt: true,
40+
updatedAt: true,
3441
})
3542
.partial({
3643
accepted: true,
@@ -43,7 +50,7 @@ export const schemaMembershipBodyParams = schemaMembershipBaseBodyParams.merge(
4350
schemaMembershipRequiredParams
4451
);
4552

46-
export const schemaMembershipPublic = Membership.merge(z.object({ team: _TeamModel }).partial());
53+
export const schemaMembershipPublic = MembershipSchema.merge(z.object({ team: TeamSchema }).partial());
4754

4855
/** We extract userId and teamId from compound ID string */
4956
export const membershipIdSchema = schemaQueryIdAsString

0 commit comments

Comments
 (0)