Skip to content

Commit 79a0936

Browse files
keithwillcodedevin-ai-integration[bot]hbjORbj
authored
refactor: remove circular dependency between prisma and app-store packages (calcom#23475)
* refactor: remove circular dependency between prisma and app-store packages - Replace EventTypeAppMetadataSchema with z.record(z.any()).optional() pattern - Remove appDataSchemas import from packages/prisma/zod-utils.ts - Add null checks in consuming packages for flexible validation - Fix test file that no longer needs @ts-expect-error directive This breaks the circular dependency while maintaining all functionality by moving strict validation to the business logic layer where operations actually happen, following existing patterns in the codebase. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: remove EventTypeAppMetadataSchema exports from prisma package - Remove EventTypeAppMetadataSchema and eventTypeAppMetadataOptionalSchema exports from prisma/zod-utils.ts - Update all importing files to use local z.record(z.any()).optional() schemas - Replace type annotations with Record<string, any> where appropriate - Maintain validation functionality while breaking circular dependency - All TypeScript compilation now passes without errors Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: complete removal of EventTypeAppMetadataSchema from remaining files - Update handleSeats/createNewSeat.ts to use local schema - Update payment handlers to use local schemas - Update eventTypes update handler to use local schema - All files now define their own validation instead of importing from prisma - Circular dependency completely eliminated Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: resolve TypeScript compilation errors - Remove duplicate z import from handleConfirmation.ts - Remove duplicate appDataSchemas import from update.handler.ts - Fix index signature errors in handlePayment.ts by using appData variable consistently - All type checks now pass successfully Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add type casting for appSlug in eventTypeService - Cast appSlug as keyof typeof apps to resolve index signature error - Maintains type safety while allowing dynamic property access Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix * remove * make zod-utils.ts in app-store * update imports * fix * fix * fix * revert unrelated change * update imports * fix * fix * revert * fix * fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: hbjORbj <sldisek783@gmail.com>
1 parent 94a5008 commit 79a0936

42 files changed

Lines changed: 89 additions & 75 deletions

Some content is hidden

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

apps/web/app/(booking-page-wrapper)/team/[slug]/[type]/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { GetServerSidePropsContext } from "next";
22
import { unstable_cache } from "next/cache";
33

4+
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
45
import { getTeamData } from "@calcom/features/ee/teams/lib/getTeamData";
56
import {
67
getEventTypeHosts,
@@ -17,7 +18,6 @@ import { UserRepository } from "@calcom/lib/server/repository/user";
1718
import { prisma } from "@calcom/prisma";
1819
import type { Prisma } from "@calcom/prisma/client";
1920
import type { SchedulingType } from "@calcom/prisma/enums";
20-
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils";
2121

2222
export async function getCachedTeamData(teamSlug: string, orgSlug: string | null) {
2323
return unstable_cache(async () => getTeamData(teamSlug, orgSlug), ["team-data", teamSlug, orgSlug ?? ""], {

apps/web/modules/apps/installation/[[...step]]/step-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { z } from "zod";
99
import checkForMultiplePaymentApps from "@calcom/app-store/_utils/payments/checkForMultiplePaymentApps";
1010
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
1111
import type { EventTypeAppSettingsComponentProps, EventTypeModel } from "@calcom/app-store/types";
12+
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
1213
import type { LocationFormValues } from "@calcom/features/eventtypes/lib/types";
1314
import { AppOnboardingSteps } from "@calcom/lib/apps/appOnboardingSteps";
1415
import { getAppOnboardingUrl } from "@calcom/lib/apps/getAppOnboardingUrl";
@@ -17,7 +18,6 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
1718
import type { LocationObject } from "@calcom/lib/location";
1819
import type { Team } from "@calcom/prisma/client";
1920
import type { eventTypeBookingFields } from "@calcom/prisma/zod-utils";
20-
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils";
2121
import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
2222
import { trpc } from "@calcom/trpc/react";
2323
import type { AppMeta } from "@calcom/types/App";

apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createRouterCaller } from "app/_trpc/context";
22
import type { GetServerSidePropsContext } from "next";
33
import { z } from "zod";
44

5+
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
56
import { orgDomainConfig } from "@calcom/ee/organizations/lib/orgDomains";
67
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
78
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
@@ -12,7 +13,7 @@ import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
1213
import { maybeGetBookingUidFromSeat } from "@calcom/lib/server/maybeGetBookingUidFromSeat";
1314
import { BookingRepository } from "@calcom/lib/server/repository/booking";
1415
import prisma from "@calcom/prisma";
15-
import { customInputSchema, eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils";
16+
import { customInputSchema } from "@calcom/prisma/zod-utils";
1617
import { meRouter } from "@calcom/trpc/server/routers/viewer/me/_router";
1718

1819
import type { inferSSRProps } from "@lib/types/inferSSRProps";

apps/web/modules/bookings/views/bookings-single-view.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager";
1313
import type { getEventLocationValue } from "@calcom/app-store/locations";
1414
import { getSuccessPageLocationMessage, guessEventLocationType } from "@calcom/app-store/locations";
1515
import { getEventTypeAppData } from "@calcom/app-store/utils";
16+
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
1617
import type { ConfigType } from "@calcom/dayjs";
1718
import dayjs from "@calcom/dayjs";
1819
import {
@@ -45,7 +46,7 @@ import { getIs24hClockFromLocalStorage, isBrowserLocale24h } from "@calcom/lib/t
4546
import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants";
4647
import { localStorage } from "@calcom/lib/webstorage";
4748
import { BookingStatus, SchedulingType } from "@calcom/prisma/enums";
48-
import { bookingMetadataSchema, eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils";
49+
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
4950
import { trpc } from "@calcom/trpc/react";
5051
import { Alert } from "@calcom/ui/components/alert";
5152
import { Avatar } from "@calcom/ui/components/avatar";

apps/web/modules/test-setup.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ vi.mock("@calcom/prisma/zod-utils", () => ({
128128
EventTypeMetaDataSchema: {
129129
parse: vi.fn(),
130130
},
131-
eventTypeMetaDataSchemaWithTypedApps: {
131+
bookingMetadataSchema: {
132132
parse: vi.fn(),
133133
},
134-
bookingMetadataSchema: {
134+
}));
135+
136+
vi.mock("@calcom/app-store/zod-utils", () => ({
137+
eventTypeMetaDataSchemaWithTypedApps: {
135138
parse: vi.fn(),
136139
},
137140
}));

apps/web/playwright/integrations-stripe.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect } from "@playwright/test";
22

3+
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
34
import prisma from "@calcom/prisma";
45
import type Prisma from "@calcom/prisma/client";
56
import { SchedulingType } from "@calcom/prisma/enums";
6-
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils";
77

88
import { test, todo } from "./lib/fixtures";
99
import type { Fixtures } from "./lib/fixtures";

packages/app-store/_utils/CRMRoundRobinSkip.ts

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

3+
import type { EventTypeAppMetadataSchema } from "@calcom/app-store/zod-utils";
34
import CrmManager from "@calcom/lib/crmManager/crmManager";
45
import logger from "@calcom/lib/logger";
56
import { prisma } from "@calcom/prisma";
67
import type { Prisma } from "@calcom/prisma/client";
7-
import type { EventTypeAppMetadataSchema } from "@calcom/prisma/zod-utils";
88
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
99

1010
export async function getCRMContactOwnerForRRLeadSkip(

packages/app-store/_utils/getEventTypeAppData.ts

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

3+
import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
34
import type { BookerEvent } from "@calcom/features/bookings/types";
4-
import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils";
55

66
export type EventTypeApps = NonNullable<
77
NonNullable<z.infer<typeof eventTypeMetaDataSchemaWithTypedApps>>["apps"]

packages/app-store/_utils/payments/checkForMultiplePaymentApps.ts

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

3-
import type { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
3+
import type { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils";
44

55
import type { appDataSchemas } from "../../apps.schemas.generated";
66

packages/app-store/_utils/payments/handlePaymentSuccess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils";
12
import { sendScheduledEmailsAndSMS } from "@calcom/emails";
23
import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation";
34
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
@@ -13,7 +14,6 @@ import prisma from "@calcom/prisma";
1314
import type { Prisma } from "@calcom/prisma/client";
1415
import { BookingStatus } from "@calcom/prisma/enums";
1516
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
16-
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
1717

1818
const log = logger.getSubLogger({ prefix: ["[handlePaymentSuccess]"] });
1919
export async function handlePaymentSuccess(paymentId: number, bookingId: number) {

0 commit comments

Comments
 (0)