From 79a09362c96eb5481cd41f40e281814742eca8ed Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Fri, 12 Sep 2025 05:57:09 -0300 Subject: [PATCH] refactor: remove circular dependency between prisma and app-store packages (#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 * 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 where appropriate - Maintain validation functionality while breaking circular dependency - All TypeScript compilation now passes without errors Co-Authored-By: keith@cal.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 * 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 * 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 * 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 --- .../team/[slug]/[type]/queries.ts | 2 +- .../installation/[[...step]]/step-view.tsx | 2 +- ...ookings-single-view.getServerSideProps.tsx | 3 ++- .../bookings/views/bookings-single-view.tsx | 3 ++- apps/web/modules/test-setup.ts | 7 +++++-- .../web/playwright/integrations-stripe.e2e.ts | 2 +- .../app-store/_utils/CRMRoundRobinSkip.ts | 2 +- .../app-store/_utils/getEventTypeAppData.ts | 2 +- .../payments/checkForMultiplePaymentApps.ts | 2 +- .../_utils/payments/handlePaymentSuccess.ts | 2 +- .../salesforce/lib}/eventTypeService.ts | 3 ++- .../lib/routingFormBookingFormHandler.ts | 2 +- packages/app-store/zod-utils.ts | 17 +++++++++++++++++ .../getAllCredentials.ts | 4 ++-- .../bookings/lib/handleCancelBooking.ts | 7 ++----- .../bookings/lib/handleConfirmation.ts | 3 ++- .../features/bookings/lib/handleNewBooking.ts | 8 +++----- .../features/bookings/lib/handlePayment.ts | 2 +- .../lib/handleSeats/create/createNewSeat.ts | 2 +- .../credentials/handleDeleteCredential.ts | 10 +++++++--- .../lib/handleChildrenEventTypes.ts | 2 +- packages/features/ee/payments/api/webhook.ts | 2 +- .../roundRobinManualReassignment.ts | 2 +- .../ee/round-robin/roundRobinReassignment.ts | 2 +- .../components/EventTypeDescription.tsx | 2 +- .../tabs/instant/EventInstantTab.tsx | 2 +- .../tabs/recurring/EventRecurringTab.tsx | 2 +- .../features/eventtypes/lib/getPublicEvent.ts | 2 +- packages/features/eventtypes/lib/types.ts | 19 ++++++++++--------- .../handleSendingAttendeeNoShowDataToApps.ts | 3 ++- packages/lib/EventManager.ts | 7 +++---- packages/lib/defaultEvents.ts | 2 +- packages/lib/event-types/getEventTypeById.ts | 3 ++- packages/lib/getPaymentAppData.ts | 2 +- packages/lib/payment/handleNoShowFee.ts | 2 +- .../payment/processNoShowFeeOnCancellation.ts | 2 +- .../shouldChargeNoShowCancellationFee.test.ts | 2 +- .../shouldChargeNoShowCancellationFee.ts | 2 +- .../event-types/hooks/useTabsNavigations.tsx | 2 +- packages/prisma/zod-utils.ts | 11 ----------- .../viewer/eventTypes/heavy/update.handler.ts | 4 ++-- .../getAllActiveWorkflows.handler.ts | 2 +- 42 files changed, 89 insertions(+), 75 deletions(-) rename packages/{lib/server/service => app-store/salesforce/lib}/eventTypeService.ts (88%) create mode 100644 packages/app-store/zod-utils.ts diff --git a/apps/web/app/(booking-page-wrapper)/team/[slug]/[type]/queries.ts b/apps/web/app/(booking-page-wrapper)/team/[slug]/[type]/queries.ts index c731894936..8b6f09836f 100644 --- a/apps/web/app/(booking-page-wrapper)/team/[slug]/[type]/queries.ts +++ b/apps/web/app/(booking-page-wrapper)/team/[slug]/[type]/queries.ts @@ -1,6 +1,7 @@ import type { GetServerSidePropsContext } from "next"; import { unstable_cache } from "next/cache"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { getTeamData } from "@calcom/features/ee/teams/lib/getTeamData"; import { getEventTypeHosts, @@ -17,7 +18,6 @@ import { UserRepository } from "@calcom/lib/server/repository/user"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import type { SchedulingType } from "@calcom/prisma/enums"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; export async function getCachedTeamData(teamSlug: string, orgSlug: string | null) { return unstable_cache(async () => getTeamData(teamSlug, orgSlug), ["team-data", teamSlug, orgSlug ?? ""], { diff --git a/apps/web/modules/apps/installation/[[...step]]/step-view.tsx b/apps/web/modules/apps/installation/[[...step]]/step-view.tsx index 76b08c3229..9646d5f356 100644 --- a/apps/web/modules/apps/installation/[[...step]]/step-view.tsx +++ b/apps/web/modules/apps/installation/[[...step]]/step-view.tsx @@ -9,6 +9,7 @@ import type { z } from "zod"; import checkForMultiplePaymentApps from "@calcom/app-store/_utils/payments/checkForMultiplePaymentApps"; import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation"; import type { EventTypeAppSettingsComponentProps, EventTypeModel } from "@calcom/app-store/types"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { LocationFormValues } from "@calcom/features/eventtypes/lib/types"; import { AppOnboardingSteps } from "@calcom/lib/apps/appOnboardingSteps"; import { getAppOnboardingUrl } from "@calcom/lib/apps/getAppOnboardingUrl"; @@ -17,7 +18,6 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { LocationObject } from "@calcom/lib/location"; import type { Team } from "@calcom/prisma/client"; import type { eventTypeBookingFields } from "@calcom/prisma/zod-utils"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import { trpc } from "@calcom/trpc/react"; import type { AppMeta } from "@calcom/types/App"; diff --git a/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx b/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx index 505d59f8b6..98530ff041 100644 --- a/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx +++ b/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx @@ -2,6 +2,7 @@ import { createRouterCaller } from "app/_trpc/context"; import type { GetServerSidePropsContext } from "next"; import { z } from "zod"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { orgDomainConfig } from "@calcom/ee/organizations/lib/orgDomains"; import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo"; @@ -12,7 +13,7 @@ import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML"; import { maybeGetBookingUidFromSeat } from "@calcom/lib/server/maybeGetBookingUidFromSeat"; import { BookingRepository } from "@calcom/lib/server/repository/booking"; import prisma from "@calcom/prisma"; -import { customInputSchema, eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; +import { customInputSchema } from "@calcom/prisma/zod-utils"; import { meRouter } from "@calcom/trpc/server/routers/viewer/me/_router"; import type { inferSSRProps } from "@lib/types/inferSSRProps"; diff --git a/apps/web/modules/bookings/views/bookings-single-view.tsx b/apps/web/modules/bookings/views/bookings-single-view.tsx index 9e9a972e00..78c8f4f141 100644 --- a/apps/web/modules/bookings/views/bookings-single-view.tsx +++ b/apps/web/modules/bookings/views/bookings-single-view.tsx @@ -13,6 +13,7 @@ import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager"; import type { getEventLocationValue } from "@calcom/app-store/locations"; import { getSuccessPageLocationMessage, guessEventLocationType } from "@calcom/app-store/locations"; import { getEventTypeAppData } from "@calcom/app-store/utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { ConfigType } from "@calcom/dayjs"; import dayjs from "@calcom/dayjs"; import { @@ -45,7 +46,7 @@ import { getIs24hClockFromLocalStorage, isBrowserLocale24h } from "@calcom/lib/t import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants"; import { localStorage } from "@calcom/lib/webstorage"; import { BookingStatus, SchedulingType } from "@calcom/prisma/enums"; -import { bookingMetadataSchema, eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; +import { bookingMetadataSchema } from "@calcom/prisma/zod-utils"; import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/components/alert"; import { Avatar } from "@calcom/ui/components/avatar"; diff --git a/apps/web/modules/test-setup.ts b/apps/web/modules/test-setup.ts index d1f0715348..25148028b1 100644 --- a/apps/web/modules/test-setup.ts +++ b/apps/web/modules/test-setup.ts @@ -128,10 +128,13 @@ vi.mock("@calcom/prisma/zod-utils", () => ({ EventTypeMetaDataSchema: { parse: vi.fn(), }, - eventTypeMetaDataSchemaWithTypedApps: { + bookingMetadataSchema: { parse: vi.fn(), }, - bookingMetadataSchema: { +})); + +vi.mock("@calcom/app-store/zod-utils", () => ({ + eventTypeMetaDataSchemaWithTypedApps: { parse: vi.fn(), }, })); diff --git a/apps/web/playwright/integrations-stripe.e2e.ts b/apps/web/playwright/integrations-stripe.e2e.ts index 05b5af67dd..df6fa114b5 100644 --- a/apps/web/playwright/integrations-stripe.e2e.ts +++ b/apps/web/playwright/integrations-stripe.e2e.ts @@ -1,9 +1,9 @@ import { expect } from "@playwright/test"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import prisma from "@calcom/prisma"; import type Prisma from "@calcom/prisma/client"; import { SchedulingType } from "@calcom/prisma/enums"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import { test, todo } from "./lib/fixtures"; import type { Fixtures } from "./lib/fixtures"; diff --git a/packages/app-store/_utils/CRMRoundRobinSkip.ts b/packages/app-store/_utils/CRMRoundRobinSkip.ts index 43d12b5b0f..683ce1f8af 100644 --- a/packages/app-store/_utils/CRMRoundRobinSkip.ts +++ b/packages/app-store/_utils/CRMRoundRobinSkip.ts @@ -1,10 +1,10 @@ import type { z } from "zod"; +import type { EventTypeAppMetadataSchema } from "@calcom/app-store/zod-utils"; import CrmManager from "@calcom/lib/crmManager/crmManager"; import logger from "@calcom/lib/logger"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; -import type { EventTypeAppMetadataSchema } from "@calcom/prisma/zod-utils"; import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; export async function getCRMContactOwnerForRRLeadSkip( diff --git a/packages/app-store/_utils/getEventTypeAppData.ts b/packages/app-store/_utils/getEventTypeAppData.ts index 299bcdf5bb..abafe50b77 100644 --- a/packages/app-store/_utils/getEventTypeAppData.ts +++ b/packages/app-store/_utils/getEventTypeAppData.ts @@ -1,7 +1,7 @@ import type { z } from "zod"; +import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { BookerEvent } from "@calcom/features/bookings/types"; -import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; export type EventTypeApps = NonNullable< NonNullable>["apps"] diff --git a/packages/app-store/_utils/payments/checkForMultiplePaymentApps.ts b/packages/app-store/_utils/payments/checkForMultiplePaymentApps.ts index aed2b8385b..a9a9cd6b7f 100644 --- a/packages/app-store/_utils/payments/checkForMultiplePaymentApps.ts +++ b/packages/app-store/_utils/payments/checkForMultiplePaymentApps.ts @@ -1,6 +1,6 @@ import type z from "zod"; -import type { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; +import type { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import type { appDataSchemas } from "../../apps.schemas.generated"; diff --git a/packages/app-store/_utils/payments/handlePaymentSuccess.ts b/packages/app-store/_utils/payments/handlePaymentSuccess.ts index 35460a41c8..ee6075dcca 100644 --- a/packages/app-store/_utils/payments/handlePaymentSuccess.ts +++ b/packages/app-store/_utils/payments/handlePaymentSuccess.ts @@ -1,3 +1,4 @@ +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import { sendScheduledEmailsAndSMS } from "@calcom/emails"; import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation"; import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials"; @@ -13,7 +14,6 @@ import prisma from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { BookingStatus } from "@calcom/prisma/enums"; import type { EventTypeMetadata } from "@calcom/prisma/zod-utils"; -import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; const log = logger.getSubLogger({ prefix: ["[handlePaymentSuccess]"] }); export async function handlePaymentSuccess(paymentId: number, bookingId: number) { diff --git a/packages/lib/server/service/eventTypeService.ts b/packages/app-store/salesforce/lib/eventTypeService.ts similarity index 88% rename from packages/lib/server/service/eventTypeService.ts rename to packages/app-store/salesforce/lib/eventTypeService.ts index 88d3646b07..adf91215c5 100644 --- a/packages/lib/server/service/eventTypeService.ts +++ b/packages/app-store/salesforce/lib/eventTypeService.ts @@ -1,7 +1,8 @@ import type { appDataSchemas } from "@calcom/app-store/apps.schemas.generated"; +import { EventTypeAppMetadataSchema } from "@calcom/app-store/zod-utils"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; -import { EventTypeMetaDataSchema, EventTypeAppMetadataSchema } from "@calcom/prisma/zod-utils"; +import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; export class EventTypeService { static async getEventTypeAppDataFromId(eventTypeId: number, appSlug: keyof typeof appDataSchemas) { diff --git a/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts b/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts index 4ecfc95417..9bbecc9d04 100644 --- a/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts +++ b/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts @@ -1,8 +1,8 @@ import { CredentialRepository } from "../../../lib/server/repository/credential"; -import { EventTypeService } from "../../../lib/server/service/eventTypeService"; import type { AttributeRoutingConfig } from "../../routing-forms/types/types"; import SalesforceCRMService from "./CrmService"; import { SalesforceRecordEnum, RoutingReasons } from "./enums"; +import { EventTypeService } from "./eventTypeService"; const routingFormBookingFormHandler = async ( attendeeEmail: string, diff --git a/packages/app-store/zod-utils.ts b/packages/app-store/zod-utils.ts new file mode 100644 index 0000000000..5f5996311a --- /dev/null +++ b/packages/app-store/zod-utils.ts @@ -0,0 +1,17 @@ +import { z } from "zod"; + +import { eventTypeMetaDataSchemaWithoutApps } from "@calcom/prisma/zod-utils"; + +import { appDataSchemas } from "./apps.schemas.generated"; + +export const EventTypeAppMetadataSchema = z.object(appDataSchemas).partial(); +export const eventTypeAppMetadataOptionalSchema = EventTypeAppMetadataSchema.optional(); + +export const eventTypeMetaDataSchemaWithTypedApps = eventTypeMetaDataSchemaWithoutApps + .unwrap() + .merge( + z.object({ + apps: eventTypeAppMetadataOptionalSchema, + }) + ) + .nullable(); diff --git a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts index 46843b6fbd..eeca15bcac 100644 --- a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts +++ b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts @@ -1,10 +1,10 @@ -import type z from "zod"; +import type { z } from "zod"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; import { UserRepository } from "@calcom/lib/server/repository/user"; import prisma from "@calcom/prisma"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; -import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import type { CredentialPayload } from "@calcom/types/Credential"; diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts index 876d43e351..e70423e794 100644 --- a/packages/features/bookings/lib/handleCancelBooking.ts +++ b/packages/features/bookings/lib/handleCancelBooking.ts @@ -2,6 +2,7 @@ import type { z } from "zod"; import { DailyLocationType } from "@calcom/app-store/constants"; import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { sendCancelledEmailsAndSMS } from "@calcom/emails"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; @@ -32,11 +33,7 @@ import prisma from "@calcom/prisma"; import type { Prisma, WorkflowReminder } from "@calcom/prisma/client"; import type { WebhookTriggerEvents } from "@calcom/prisma/enums"; import { BookingStatus } from "@calcom/prisma/enums"; -import { - bookingMetadataSchema, - eventTypeMetaDataSchemaWithTypedApps, - bookingCancelInput, -} from "@calcom/prisma/zod-utils"; +import { bookingMetadataSchema, bookingCancelInput } from "@calcom/prisma/zod-utils"; import type { EventTypeMetadata } from "@calcom/prisma/zod-utils"; import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util"; import type { CalendarEvent } from "@calcom/types/Calendar"; diff --git a/packages/features/bookings/lib/handleConfirmation.ts b/packages/features/bookings/lib/handleConfirmation.ts index 0fc3ce0eeb..f53f0598c8 100644 --- a/packages/features/bookings/lib/handleConfirmation.ts +++ b/packages/features/bookings/lib/handleConfirmation.ts @@ -1,3 +1,4 @@ +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import { scheduleMandatoryReminder } from "@calcom/ee/workflows/lib/reminders/scheduleMandatoryReminder"; import { sendScheduledEmailsAndSMS } from "@calcom/emails"; import { @@ -23,7 +24,7 @@ import type { Prisma } from "@calcom/prisma/client"; import type { SchedulingType } from "@calcom/prisma/enums"; import { BookingStatus, WebhookTriggerEvents, WorkflowTriggerEvents } from "@calcom/prisma/enums"; import type { PlatformClientParams } from "@calcom/prisma/zod-utils"; -import { EventTypeMetaDataSchema, eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; +import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util"; import type { AdditionalInformation, CalendarEvent } from "@calcom/types/Calendar"; diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 5ac724d117..8556326ac8 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -10,6 +10,8 @@ import { OrganizerDefaultConferencingAppType, } from "@calcom/app-store/locations"; import { getAppFromSlug } from "@calcom/app-store/utils"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { scheduleMandatoryReminder } from "@calcom/ee/workflows/lib/reminders/scheduleMandatoryReminder"; import getICalUID from "@calcom/emails/lib/getICalUID"; @@ -75,11 +77,7 @@ import { WorkflowTriggerEvents, CreationSource, } from "@calcom/prisma/enums"; -import { - eventTypeAppMetadataOptionalSchema, - eventTypeMetaDataSchemaWithTypedApps, - userMetadata as userMetadataSchema, -} from "@calcom/prisma/zod-utils"; +import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils"; import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util"; import type { AdditionalInformation, diff --git a/packages/features/bookings/lib/handlePayment.ts b/packages/features/bookings/lib/handlePayment.ts index 83fe57fc6d..26a397bcd7 100644 --- a/packages/features/bookings/lib/handlePayment.ts +++ b/packages/features/bookings/lib/handlePayment.ts @@ -1,7 +1,7 @@ import { PaymentServiceMap } from "@calcom/app-store/payment.services.generated"; import type { EventTypeAppsList } from "@calcom/app-store/utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { AppCategories, Prisma, EventType } from "@calcom/prisma/client"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import type { CalendarEvent } from "@calcom/types/Calendar"; import type { IAbstractPaymentService } from "@calcom/types/PaymentService"; diff --git a/packages/features/bookings/lib/handleSeats/create/createNewSeat.ts b/packages/features/bookings/lib/handleSeats/create/createNewSeat.ts index 12b0f9e950..94f3a0de92 100644 --- a/packages/features/bookings/lib/handleSeats/create/createNewSeat.ts +++ b/packages/features/bookings/lib/handleSeats/create/createNewSeat.ts @@ -2,6 +2,7 @@ import { cloneDeep } from "lodash"; import { uuid } from "short-uuid"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import { sendScheduledSeatsEmailsAndSMS } from "@calcom/emails"; import { refreshCredentials } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials"; import { handlePayment } from "@calcom/features/bookings/lib/handlePayment"; @@ -15,7 +16,6 @@ import { HttpError } from "@calcom/lib/http-error"; import prisma from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { BookingStatus } from "@calcom/prisma/enums"; -import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; import { findBookingQuery } from "../../handleNewBooking/findBookingQuery"; import type { IEventTypePaymentCredentialType } from "../../handleNewBooking/types"; diff --git a/packages/features/credentials/handleDeleteCredential.ts b/packages/features/credentials/handleDeleteCredential.ts index a785086985..6111aaced3 100644 --- a/packages/features/credentials/handleDeleteCredential.ts +++ b/packages/features/credentials/handleDeleteCredential.ts @@ -2,6 +2,11 @@ import z from "zod"; import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData"; +import { + type EventTypeAppMetadataSchema, + eventTypeAppMetadataOptionalSchema, +} from "@calcom/app-store/zod-utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { sendCancelledEmailsAndSMS } from "@calcom/emails"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; import { deleteWebhookScheduledTriggers } from "@calcom/features/webhooks/lib/scheduleTrigger"; @@ -15,9 +20,8 @@ import { bookingMinimalSelect, prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { AppCategories, BookingStatus } from "@calcom/prisma/enums"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; -import type { EventTypeAppMetadataSchema, EventTypeMetadata } from "@calcom/prisma/zod-utils"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; -import { EventTypeMetaDataSchema, eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; +import type { EventTypeMetadata } from "@calcom/prisma/zod-utils"; +import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils"; type App = { diff --git a/packages/features/ee/managed-event-types/lib/handleChildrenEventTypes.ts b/packages/features/ee/managed-event-types/lib/handleChildrenEventTypes.ts index 7cb5d229d4..d6b227b830 100644 --- a/packages/features/ee/managed-event-types/lib/handleChildrenEventTypes.ts +++ b/packages/features/ee/managed-event-types/lib/handleChildrenEventTypes.ts @@ -1,12 +1,12 @@ // eslint-disable-next-line no-restricted-imports import type { DeepMockProxy } from "vitest-mock-extended"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { sendSlugReplacementEmail } from "@calcom/emails/email-manager"; import { getTranslation } from "@calcom/lib/server/i18n"; import type { PrismaClient } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { SchedulingType } from "@calcom/prisma/enums"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import { allManagedEventTypeProps, unlockedManagedEventTypeProps } from "@calcom/prisma/zod-utils"; import { EventTypeSchema } from "@calcom/prisma/zod/modelSchema/EventTypeSchema"; diff --git a/packages/features/ee/payments/api/webhook.ts b/packages/features/ee/payments/api/webhook.ts index dd735d50f8..40ef94a325 100644 --- a/packages/features/ee/payments/api/webhook.ts +++ b/packages/features/ee/payments/api/webhook.ts @@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import type Stripe from "stripe"; import { handlePaymentSuccess } from "@calcom/app-store/_utils/payments/handlePaymentSuccess"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails"; import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation"; import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials"; @@ -20,7 +21,6 @@ import { safeStringify } from "@calcom/lib/safeStringify"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { BookingStatus } from "@calcom/prisma/enums"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; const log = logger.getSubLogger({ prefix: ["[paymentWebhook]"] }); diff --git a/packages/features/ee/round-robin/roundRobinManualReassignment.ts b/packages/features/ee/round-robin/roundRobinManualReassignment.ts index 9c4bf20fa0..7cef29f663 100644 --- a/packages/features/ee/round-robin/roundRobinManualReassignment.ts +++ b/packages/features/ee/round-robin/roundRobinManualReassignment.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line no-restricted-imports import { cloneDeep } from "lodash"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { sendRoundRobinReassignedEmailsAndSMS, @@ -34,7 +35,6 @@ import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat"; import { prisma } from "@calcom/prisma"; import { WorkflowActions, WorkflowMethods, WorkflowTriggerEvents } from "@calcom/prisma/enums"; import type { EventTypeMetadata, PlatformClientParams } from "@calcom/prisma/zod-utils"; -import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; import type { CalendarEvent } from "@calcom/types/Calendar"; import { handleRescheduleEventManager } from "./handleRescheduleEventManager"; diff --git a/packages/features/ee/round-robin/roundRobinReassignment.ts b/packages/features/ee/round-robin/roundRobinReassignment.ts index b48c0a8898..f0793d1207 100644 --- a/packages/features/ee/round-robin/roundRobinReassignment.ts +++ b/packages/features/ee/round-robin/roundRobinReassignment.ts @@ -2,6 +2,7 @@ import { cloneDeep } from "lodash"; import { OrganizerDefaultConferencingAppType, getLocationValueForDB } from "@calcom/app-store/locations"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { sendRoundRobinReassignedEmailsAndSMS, @@ -33,7 +34,6 @@ import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat"; import { prisma } from "@calcom/prisma"; import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils"; import type { EventTypeMetadata, PlatformClientParams } from "@calcom/prisma/zod-utils"; -import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; import type { CalendarEvent } from "@calcom/types/Calendar"; import { handleRescheduleEventManager } from "./handleRescheduleEventManager"; diff --git a/packages/features/eventtypes/components/EventTypeDescription.tsx b/packages/features/eventtypes/components/EventTypeDescription.tsx index 854465f16b..e01835b38a 100644 --- a/packages/features/eventtypes/components/EventTypeDescription.tsx +++ b/packages/features/eventtypes/components/EventTypeDescription.tsx @@ -1,5 +1,6 @@ import { useMemo } from "react"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { Price } from "@calcom/features/bookings/components/event-meta/Price"; import { PriceIcon } from "@calcom/features/bookings/components/event-meta/PriceIcon"; import { getPaymentAppData } from "@calcom/lib/getPaymentAppData"; @@ -9,7 +10,6 @@ import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML"; import type { baseEventTypeSelect } from "@calcom/prisma"; import type { Prisma, EventType } from "@calcom/prisma/client"; import { SchedulingType } from "@calcom/prisma/enums"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import classNames from "@calcom/ui/classNames"; import { Badge } from "@calcom/ui/components/badge"; diff --git a/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx b/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx index b3938b4c13..99318ab73a 100644 --- a/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx +++ b/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx @@ -1,6 +1,6 @@ +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types"; import { getPaymentAppData } from "@calcom/lib/getPaymentAppData"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import InstantEventController from "./InstantEventController"; diff --git a/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx b/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx index 630d7a3e4b..b13d1387cf 100644 --- a/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx +++ b/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx @@ -1,5 +1,5 @@ +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { getPaymentAppData } from "@calcom/lib/getPaymentAppData"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import type { RecurringEventControllerProps } from "./RecurringEventController"; import RecurringEventController from "./RecurringEventController"; diff --git a/packages/features/eventtypes/lib/getPublicEvent.ts b/packages/features/eventtypes/lib/getPublicEvent.ts index 6053c93a10..8928a96ad7 100644 --- a/packages/features/eventtypes/lib/getPublicEvent.ts +++ b/packages/features/eventtypes/lib/getPublicEvent.ts @@ -1,6 +1,7 @@ import type { LocationObject } from "@calcom/app-store/locations"; import { privacyFilteredLocations } from "@calcom/app-store/locations"; import { getAppFromSlug } from "@calcom/app-store/utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields"; import { getSlugOrRequestedSlug } from "@calcom/features/ee/organizations/lib/orgDomains"; @@ -19,7 +20,6 @@ import type { Team } from "@calcom/prisma/client"; import type { BookerLayoutSettings } from "@calcom/prisma/zod-utils"; import { BookerLayouts, - eventTypeMetaDataSchemaWithTypedApps, bookerLayoutOptions, bookerLayouts as bookerLayoutsSchema, customInputSchema, diff --git a/packages/features/eventtypes/lib/types.ts b/packages/features/eventtypes/lib/types.ts index 91070bef5b..90070c80b9 100644 --- a/packages/features/eventtypes/lib/types.ts +++ b/packages/features/eventtypes/lib/types.ts @@ -1,20 +1,21 @@ import { z } from "zod"; +import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { ChildrenEventType } from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect"; import type { IntervalLimit } from "@calcom/lib/intervalLimits/intervalLimitSchema"; import type { EventLocationType } from "@calcom/lib/location"; import type { AttributesQueryValue } from "@calcom/lib/raqb/types"; import type { EventTypeTranslation } from "@calcom/prisma/client"; -import type { PeriodType } from "@calcom/prisma/enums"; -import { SchedulingType } from "@calcom/prisma/enums"; -import type { - BookerLayoutSettings, - customInputSchema, - eventTypeMetaDataSchemaWithTypedApps, - eventTypeBookingFields, - eventTypeColor, +import { type PeriodType, SchedulingType } from "@calcom/prisma/enums"; +import { + eventTypeLocations, + EventTypeMetaDataSchema, + eventTypeSlug, + type BookerLayoutSettings, } from "@calcom/prisma/zod-utils"; -import { eventTypeSlug, eventTypeLocations, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; +import type { customInputSchema } from "@calcom/prisma/zod-utils"; +import type { eventTypeBookingFields } from "@calcom/prisma/zod-utils"; +import type { eventTypeColor } from "@calcom/prisma/zod-utils"; import type { RouterOutputs, RouterInputs } from "@calcom/trpc/react"; import type { RecurringEvent } from "@calcom/types/Calendar"; diff --git a/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts b/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts index 915ea0acb5..e499bdf89a 100644 --- a/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts +++ b/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts @@ -1,10 +1,11 @@ import type { z } from "zod"; import type { eventTypeAppCardZod } from "@calcom/app-store/eventTypeAppCardZod"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import CrmManager from "@calcom/lib/crmManager/crmManager"; import logger from "@calcom/lib/logger"; import prisma from "@calcom/prisma"; -import { eventTypeAppMetadataOptionalSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; +import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import type { NoShowAttendees } from "../handleMarkNoShow"; import { noShowEnabledApps } from "./noShowEnabledApps"; diff --git a/packages/lib/EventManager.ts b/packages/lib/EventManager.ts index d665b3c3b8..e2a77d3979 100644 --- a/packages/lib/EventManager.ts +++ b/packages/lib/EventManager.ts @@ -24,7 +24,6 @@ import { CredentialRepository } from "@calcom/lib/server/repository/credential"; import { prisma } from "@calcom/prisma"; import type { DestinationCalendar, BookingReference } from "@calcom/prisma/client"; import { createdEventSchema } from "@calcom/prisma/zod-utils"; -import type { EventTypeAppMetadataSchema } from "@calcom/prisma/zod-utils"; import type { AdditionalInformation, CalendarEvent, NewCalendarEventType } from "@calcom/types/Calendar"; import type { CredentialForCalendarService } from "@calcom/types/Credential"; import type { Event } from "@calcom/types/Event"; @@ -130,20 +129,20 @@ type createdEventSchema = z.infer; export type EventManagerInitParams = { user: EventManagerUser; - eventTypeAppMetadata?: z.infer; + eventTypeAppMetadata?: Record; }; export default class EventManager { calendarCredentials: CredentialForCalendarService[]; videoCredentials: CredentialForCalendarService[]; crmCredentials: CredentialForCalendarService[]; - appOptions?: z.infer; + appOptions?: Record; /** * Takes an array of credentials and initializes a new instance of the EventManager. * * @param user */ - constructor(user: EventManagerUser, eventTypeAppMetadata?: z.infer) { + constructor(user: EventManagerUser, eventTypeAppMetadata?: Record) { log.silly("Initializing EventManager", safeStringify({ user: getPiiFreeUser(user) })); const appCredentials = getApps(user.credentials, true).flatMap((app) => app.credentials.map((creds) => ({ ...creds, appName: app.name })) diff --git a/packages/lib/defaultEvents.ts b/packages/lib/defaultEvents.ts index 684ccfe29d..511c135288 100644 --- a/packages/lib/defaultEvents.ts +++ b/packages/lib/defaultEvents.ts @@ -4,7 +4,7 @@ import type { Prisma, SelectedCalendar } from "@calcom/prisma/client"; import { PeriodType, SchedulingType } from "@calcom/prisma/enums"; import type { userSelect } from "@calcom/prisma/selects"; import type { CustomInputSchema } from "@calcom/prisma/zod-utils"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import type { CredentialPayload } from "@calcom/types/Credential"; diff --git a/packages/lib/event-types/getEventTypeById.ts b/packages/lib/event-types/getEventTypeById.ts index 68169086e6..3cbd419eec 100644 --- a/packages/lib/event-types/getEventTypeById.ts +++ b/packages/lib/event-types/getEventTypeById.ts @@ -1,6 +1,7 @@ //import "server-only"; import { getLocationGroupedOptions } from "@calcom/app-store/server"; import { getEventTypeAppData } from "@calcom/app-store/utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields"; import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl"; import { parseBookingLimit } from "@calcom/lib/intervalLimits/isBookingLimits"; @@ -14,7 +15,7 @@ import { UserRepository } from "@calcom/lib/server/repository/user"; import type { PrismaClient } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { SchedulingType, MembershipRole } from "@calcom/prisma/enums"; -import { customInputSchema, eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; +import { customInputSchema } from "@calcom/prisma/zod-utils"; import { TRPCError } from "@trpc/server"; diff --git a/packages/lib/getPaymentAppData.ts b/packages/lib/getPaymentAppData.ts index 113605b82c..30e135efc1 100644 --- a/packages/lib/getPaymentAppData.ts +++ b/packages/lib/getPaymentAppData.ts @@ -4,9 +4,9 @@ import { getEventTypeAppData } from "@calcom/app-store/_utils/getEventTypeAppDat import type { appDataSchemas } from "@calcom/app-store/apps.schemas.generated"; import type { appDataSchema, paymentOptionEnum } from "@calcom/app-store/stripepayment/zod"; import type { EventTypeAppsList } from "@calcom/app-store/utils"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import type { BookerEvent } from "@calcom/features/bookings/types"; import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; export function getPaymentAppData( _eventType: Pick & { diff --git a/packages/lib/payment/handleNoShowFee.ts b/packages/lib/payment/handleNoShowFee.ts index 78cd5af6b6..b5f102366f 100644 --- a/packages/lib/payment/handleNoShowFee.ts +++ b/packages/lib/payment/handleNoShowFee.ts @@ -1,5 +1,6 @@ // eslint-disable-next-line import { PaymentServiceMap } from "@calcom/app-store/payment.services.generated"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { sendNoShowFeeChargedEmail } from "@calcom/emails"; import { ErrorCode } from "@calcom/lib/errorCodes"; @@ -11,7 +12,6 @@ import { MembershipRepository } from "@calcom/lib/server/repository/membership"; import { TeamRepository } from "@calcom/lib/server/repository/team"; import prisma from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import type { CalendarEvent } from "@calcom/types/Calendar"; import type { IAbstractPaymentService } from "@calcom/types/PaymentService"; diff --git a/packages/lib/payment/processNoShowFeeOnCancellation.ts b/packages/lib/payment/processNoShowFeeOnCancellation.ts index dd57c4bfd1..39f73dc103 100644 --- a/packages/lib/payment/processNoShowFeeOnCancellation.ts +++ b/packages/lib/payment/processNoShowFeeOnCancellation.ts @@ -1,7 +1,7 @@ +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import logger from "@calcom/lib/logger"; import { MembershipRepository } from "@calcom/lib/server/repository/membership"; import type { Payment } from "@calcom/prisma/client"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import { handleNoShowFee } from "./handleNoShowFee"; import { shouldChargeNoShowCancellationFee } from "./shouldChargeNoShowCancellationFee"; diff --git a/packages/lib/payment/shouldChargeNoShowCancellationFee.test.ts b/packages/lib/payment/shouldChargeNoShowCancellationFee.test.ts index 126e7fc1df..b32ab91040 100644 --- a/packages/lib/payment/shouldChargeNoShowCancellationFee.test.ts +++ b/packages/lib/payment/shouldChargeNoShowCancellationFee.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi, beforeAll } from "vitest"; import type { z } from "zod"; -import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; +import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { shouldChargeNoShowCancellationFee } from "./shouldChargeNoShowCancellationFee"; diff --git a/packages/lib/payment/shouldChargeNoShowCancellationFee.ts b/packages/lib/payment/shouldChargeNoShowCancellationFee.ts index ca1bc9ec8a..44bfa9e027 100644 --- a/packages/lib/payment/shouldChargeNoShowCancellationFee.ts +++ b/packages/lib/payment/shouldChargeNoShowCancellationFee.ts @@ -1,6 +1,6 @@ import type { z } from "zod"; -import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; +import type { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; export const shouldChargeNoShowCancellationFee = ({ eventTypeMetadata, diff --git a/packages/platform/atoms/event-types/hooks/useTabsNavigations.tsx b/packages/platform/atoms/event-types/hooks/useTabsNavigations.tsx index 8ed05ccf1f..6dec69eeee 100644 --- a/packages/platform/atoms/event-types/hooks/useTabsNavigations.tsx +++ b/packages/platform/atoms/event-types/hooks/useTabsNavigations.tsx @@ -5,6 +5,7 @@ import type { TFunction } from "i18next"; import { useMemo } from "react"; import type { UseFormReturn } from "react-hook-form"; +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager"; import type { Workflow } from "@calcom/features/ee/workflows/lib/types"; import type { @@ -15,7 +16,6 @@ import type { } from "@calcom/features/eventtypes/lib/types"; import { getPaymentAppData } from "@calcom/lib/getPaymentAppData"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import type { VerticalTabItemProps } from "@calcom/ui/components/navigation"; type Props = { diff --git a/packages/prisma/zod-utils.ts b/packages/prisma/zod-utils.ts index 6ca8946d2a..c0a2558ca9 100644 --- a/packages/prisma/zod-utils.ts +++ b/packages/prisma/zod-utils.ts @@ -11,7 +11,6 @@ import type { ZodTypeAny, } from "zod"; -import { appDataSchemas } from "@calcom/app-store/apps.schemas.generated"; import { isPasswordValid } from "@calcom/features/auth/lib/isPasswordValid"; import type { FieldType as FormBuilderFieldType } from "@calcom/features/form-builder/schema"; import { fieldsSchema as formBuilderFieldsSchema } from "@calcom/features/form-builder/schema"; @@ -83,9 +82,6 @@ export type BookerLayoutSettings = z.infer; export const RequiresConfirmationThresholdUnits: z.ZodType = z.enum(["hours", "minutes"]); -export const EventTypeAppMetadataSchema = z.object(appDataSchemas).partial(); -export const eventTypeAppMetadataOptionalSchema = EventTypeAppMetadataSchema.optional(); - const _eventTypeMetaDataSchemaWithoutApps = z.object({ smartContractAddress: z.string().optional(), blockchainId: z.number().optional(), @@ -136,13 +132,6 @@ export const eventTypeMetaDataSchemaWithUntypedApps = _eventTypeMetaDataSchemaWi export const EventTypeMetaDataSchema = eventTypeMetaDataSchemaWithUntypedApps.nullable(); export const eventTypeMetaDataSchemaWithoutApps = _eventTypeMetaDataSchemaWithoutApps.nullable(); -export const eventTypeMetaDataSchemaWithTypedApps = _eventTypeMetaDataSchemaWithoutApps - .merge( - z.object({ - apps: eventTypeAppMetadataOptionalSchema, - }) - ) - .nullable(); export type EventTypeMetadata = z.infer; diff --git a/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts b/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts index 421072a4de..2868f017ae 100644 --- a/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts +++ b/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts @@ -2,6 +2,7 @@ import type { NextApiResponse, GetServerSidePropsContext } from "next"; import type { appDataSchemas } from "@calcom/app-store/apps.schemas.generated"; import { DailyLocationType } from "@calcom/app-store/constants"; +import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import updateChildrenEventTypes from "@calcom/features/ee/managed-event-types/lib/handleChildrenEventTypes"; import { allowDisablingAttendeeConfirmationEmails, @@ -25,20 +26,19 @@ import { EventTypeAutoTranslatedField, RRTimestampBasis, } from "@calcom/prisma/enums"; -import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils"; import { eventTypeLocations } from "@calcom/prisma/zod-utils"; import { TRPCError } from "@trpc/server"; import type { TrpcSessionUser } from "../../../../types"; import { setDestinationCalendarHandler } from "../../../viewer/calendars/setDestinationCalendar.handler"; -import type { TUpdateInputSchema } from "./update.schema"; import { ensureUniqueBookingFields, ensureEmailOrPhoneNumberIsPresent, handleCustomInputs, handlePeriodType, } from "../util"; +import type { TUpdateInputSchema } from "./update.schema"; type SessionUser = NonNullable; diff --git a/packages/trpc/server/routers/viewer/workflows/getAllActiveWorkflows.handler.ts b/packages/trpc/server/routers/viewer/workflows/getAllActiveWorkflows.handler.ts index 706eaa58c6..d580cf3416 100644 --- a/packages/trpc/server/routers/viewer/workflows/getAllActiveWorkflows.handler.ts +++ b/packages/trpc/server/routers/viewer/workflows/getAllActiveWorkflows.handler.ts @@ -1,5 +1,5 @@ +import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils"; import { isTeamMember } from "@calcom/lib/server/queries/teams"; -import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/prisma/zod-utils"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; import { TRPCError } from "@trpc/server";