Scheduling infrastructure for absolutely everyone.
refactor: circular deps between app store and lib [3] (#23742)
Benny Joo3aab13b4daaf
diff --git a/apps/api/v2/package.json b/apps/api/v2/package.jsonindex 4e7896b91dc..fadedd32a4b 100644--- a/apps/api/v2/package.json+++ b/apps/api/v2/package.json@@ -38,7 +38,7 @@"@axiomhq/winston": "^1.2.0","@calcom/platform-constants": "*","@calcom/platform-enums": "*",- "@calcom/platform-libraries": "npm:@calcom/[email protected]",+ "@calcom/platform-libraries": "npm:@calcom/[email protected]","@calcom/platform-types": "*","@calcom/platform-utils": "*","@calcom/prisma": "*",diff --git a/apps/api/v2/src/modules/atoms/controllers/atoms.verification.controller.ts b/apps/api/v2/src/modules/atoms/controllers/atoms.verification.controller.tsindex 77829716d46..9d17044cded 100644--- a/apps/api/v2/src/modules/atoms/controllers/atoms.verification.controller.ts+++ b/apps/api/v2/src/modules/atoms/controllers/atoms.verification.controller.ts@@ -79,13 +79,13 @@ export class AtomsVerificationController {@Version(VERSION_NEUTRAL)@HttpCode(HttpStatus.OK)async verifyEmailCode(@Body() body: VerifyEmailCodeInput): Promise<VerifyEmailCodeOutput> {- const verified = await this.verificationService.verifyEmailCodeUnAuthenticated({+ await this.verificationService.verifyEmailCodeUnAuthenticated({email: body.email,code: body.code,});return {- data: { verified },+ data: { verified: true },status: SUCCESS_STATUS,};}diff --git a/apps/web/app/(use-page-wrapper)/payment/[uid]/PaymentPage.tsx b/apps/web/app/(use-page-wrapper)/payment/[uid]/PaymentPage.tsxindex 56b3e4b96ec..f2000cd208f 100644--- a/apps/web/app/(use-page-wrapper)/payment/[uid]/PaymentPage.tsx+++ b/apps/web/app/(use-page-wrapper)/payment/[uid]/PaymentPage.tsx@@ -5,6 +5,7 @@ import dynamic from "next/dynamic";import type { FC } from "react";import { useEffect, useState } from "react";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { getSuccessPageLocationMessage } from "@calcom/app-store/locations";import dayjs from "@calcom/dayjs";import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";@@ -12,7 +13,6 @@ import { PayIcon } from "@calcom/features/bookings/components/event-meta/PayIconimport { Price } from "@calcom/features/bookings/components/event-meta/Price";import type { PaymentPageProps } from "@calcom/features/ee/payments/pages/payment";import { APP_NAME, WEBSITE_URL } from "@calcom/lib/constants";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useLocale } from "@calcom/lib/hooks/useLocale";import useTheme from "@calcom/lib/hooks/useTheme";import { getIs24hClockFromLocalStorage, isBrowserLocale24h } from "@calcom/lib/timeFormat";diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsxindex dea75e057cd..44079e90c49 100644--- a/apps/web/components/booking/BookingListItem.tsx+++ b/apps/web/components/booking/BookingListItem.tsx@@ -2,6 +2,7 @@ import Link from "next/link";import { useState } from "react";import { Controller, useFieldArray, useForm } from "react-hook-form";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import type { getEventLocationValue } from "@calcom/app-store/locations";import { getSuccessPageLocationMessage, guessEventLocationType } from "@calcom/app-store/locations";import dayjs from "@calcom/dayjs";@@ -11,7 +12,6 @@ import { Dialog } from "@calcom/features/components/controlled-dialog";import { MeetingSessionDetailsDialog } from "@calcom/features/ee/video/MeetingSessionDetailsDialog";import ViewRecordingsDialog from "@calcom/features/ee/video/ViewRecordingsDialog";import { formatTime } from "@calcom/lib/dayjs";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useCopy } from "@calcom/lib/hooks/useCopy";import { useLocale } from "@calcom/lib/hooks/useLocale";import { useGetTheme } from "@calcom/lib/hooks/useTheme";diff --git a/apps/web/components/booking/CancelBooking.tsx b/apps/web/components/booking/CancelBooking.tsxindex e53a0e7349b..0376f3291ef 100644--- a/apps/web/components/booking/CancelBooking.tsx+++ b/apps/web/components/booking/CancelBooking.tsx@@ -3,10 +3,10 @@import { useCallback, useState } from "react";import { sdkActionManager } from "@calcom/embed-core/embed-iframe";+import { shouldChargeNoShowCancellationFee } from "@calcom/features/bookings/lib/payment/shouldChargeNoShowCancellationFee";import { useLocale } from "@calcom/lib/hooks/useLocale";import { useRefreshData } from "@calcom/lib/hooks/useRefreshData";import { useTelemetry } from "@calcom/lib/hooks/useTelemetry";-import { shouldChargeNoShowCancellationFee } from "@calcom/lib/payment/shouldChargeNoShowCancellationFee";import { collectPageParameters, telemetryEventTypes } from "@calcom/lib/telemetry";import type { RecurringEvent } from "@calcom/types/Calendar";import { Button } from "@calcom/ui/components/button";diff --git a/apps/web/components/booking/__tests__/CancelBooking.cancellationFee.test.tsx b/apps/web/components/booking/__tests__/CancelBooking.cancellationFee.test.tsxindex 39f09e4befb..00c57c279b0 100644--- a/apps/web/components/booking/__tests__/CancelBooking.cancellationFee.test.tsx+++ b/apps/web/components/booking/__tests__/CancelBooking.cancellationFee.test.tsx@@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react";import * as React from "react";import { describe, expect, it, vi, beforeAll } from "vitest";-import * as shouldChargeModule from "@calcom/lib/payment/shouldChargeNoShowCancellationFee";+import * as shouldChargeModule from "@calcom/features/bookings/lib/payment/shouldChargeNoShowCancellationFee";import CancelBooking from "../CancelBooking";@@ -76,7 +76,7 @@ vi.mock("next/router", () => ({}),}));-vi.mock("@calcom/lib/payment/shouldChargeNoShowCancellationFee", () => ({+vi.mock("@calcom/features/bookings/lib/payment/shouldChargeNoShowCancellationFee", () => ({shouldChargeNoShowCancellationFee: vi.fn(),}));diff --git a/packages/app-store/_utils/getConnectedApps.ts b/packages/app-store/_utils/getConnectedApps.tsindex a0f841e73da..fdbe187bfa8 100644--- a/packages/app-store/_utils/getConnectedApps.ts+++ b/packages/app-store/_utils/getConnectedApps.ts@@ -1,5 +1,4 @@import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";-import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";import getInstallCountPerApp from "@calcom/lib/apps/getInstallCountPerApp";import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential/clientAndServer";import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials";@@ -11,6 +10,7 @@ import type { TDependencyData } from "../_appRegistry";import { PaymentServiceMap } from "../payment.services.generated";import type { CredentialOwner } from "../types";import { getAppFromSlug } from "../utils";+import getEnabledAppsFromCredentials from "./getEnabledAppsFromCredentials";export type ConnectedApps = Awaited<ReturnType<typeof getConnectedApps>>;type InputSchema = {diff --git a/packages/lib/apps/getEnabledAppsFromCredentials.ts b/packages/app-store/_utils/getEnabledAppsFromCredentials.tssimilarity index 95%rename from packages/lib/apps/getEnabledAppsFromCredentials.tsrename to packages/app-store/_utils/getEnabledAppsFromCredentials.tsindex 0d7c940add5..5148b47eff5 100644--- a/packages/lib/apps/getEnabledAppsFromCredentials.ts+++ b/packages/app-store/_utils/getEnabledAppsFromCredentials.ts@@ -1,9 +1,9 @@import type { CredentialDataWithTeamName } from "@calcom/app-store/utils";-import getApps from "@calcom/app-store/utils";+import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";import { prisma } from "@calcom/prisma";import type { Prisma } from "@calcom/prisma/client";-import { isDelegationCredential } from "../delegationCredential/clientAndServer";+import getApps from "../utils";type EnabledApp = ReturnType<typeof getApps>[number] & { enabled: boolean };diff --git a/packages/lib/getPaymentAppData.ts b/packages/app-store/_utils/payments/getPaymentAppData.tssimilarity index 84%rename from packages/lib/getPaymentAppData.tsrename to packages/app-store/_utils/payments/getPaymentAppData.tsindex 30e135efc14..5b515d238bc 100644--- a/packages/lib/getPaymentAppData.ts+++ b/packages/app-store/_utils/payments/getPaymentAppData.ts@@ -1,13 +1,14 @@import type { z } from "zod";-import { getEventTypeAppData } from "@calcom/app-store/_utils/getEventTypeAppData";-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 type { appDataSchemas } from "../../apps.schemas.generated";+import type { appDataSchema, paymentOptionEnum } from "../../stripepayment/zod";+import type { EventTypeAppsList } from "../../utils";+import { eventTypeMetaDataSchemaWithTypedApps } from "../../zod-utils";+import { getEventTypeAppData } from "../getEventTypeAppData";+export function getPaymentAppData(_eventType: Pick<BookerEvent, "price" | "currency"> & {metadata: z.infer<typeof EventTypeMetaDataSchema>;diff --git a/packages/app-store/_utils/payments/handlePaymentSuccess.ts b/packages/app-store/_utils/payments/handlePaymentSuccess.tsindex ee6075dcca2..ef8ef72672c 100644--- a/packages/app-store/_utils/payments/handlePaymentSuccess.ts+++ b/packages/app-store/_utils/payments/handlePaymentSuccess.ts@@ -4,12 +4,12 @@ import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doimport { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";import { handleBookingRequested } from "@calcom/features/bookings/lib/handleBookingRequested";import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";+import { getBooking } from "@calcom/features/bookings/lib/payment/getBooking";import { getPlatformParams } from "@calcom/features/platform-oauth-client/get-platform-params";import { PlatformOAuthClientRepository } from "@calcom/features/platform-oauth-client/platform-oauth-client.repository";import EventManager, { placeholderCreatedEvent } from "@calcom/lib/EventManager";import { HttpError as HttpCode } from "@calcom/lib/http-error";import logger from "@calcom/lib/logger";-import { getBooking } from "@calcom/lib/payment/getBooking";import prisma from "@calcom/prisma";import type { Prisma } from "@calcom/prisma/client";import { BookingStatus } from "@calcom/prisma/enums";diff --git a/packages/app-store/server.ts b/packages/app-store/server.tsindex 4142accc007..a9467a93ac4 100644--- a/packages/app-store/server.ts+++ b/packages/app-store/server.ts@@ -1,7 +1,6 @@import type { TFunction } from "i18next";import { defaultVideoAppCategories } from "@calcom/app-store/utils";-import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";import {buildNonDelegationCredentials,enrichUserWithDelegationConferencingCredentialsWithoutOrgId,@@ -11,6 +10,7 @@ import type { Prisma } from "@calcom/prisma/client";import { AppCategories } from "@calcom/prisma/enums";import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";+import getEnabledAppsFromCredentials from "./_utils/getEnabledAppsFromCredentials";import { defaultLocations } from "./locations";export async function getLocationGroupedOptions(diff --git a/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx b/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsxindex d3834b3d063..c0c9699c8ac 100644--- a/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx+++ b/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx@@ -3,13 +3,13 @@ import Link from "next/link";import { useMemo, useState } from "react";import type { FieldError } from "react-hook-form";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { useIsPlatformBookerEmbed } from "@calcom/atoms/hooks/useIsPlatformBookerEmbed";import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";import type { BookerEvent } from "@calcom/features/bookings/types";import ServerTrans from "@calcom/lib/components/ServerTrans";import { WEBSITE_PRIVACY_POLICY_URL, WEBSITE_TERMS_URL } from "@calcom/lib/constants";import { ErrorCode } from "@calcom/lib/errorCodes";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useLocale } from "@calcom/lib/hooks/useLocale";import type { TimeFormat } from "@calcom/lib/timeFormat";import { Alert } from "@calcom/ui/components/alert";diff --git a/packages/features/bookings/components/AvailableTimes.tsx b/packages/features/bookings/components/AvailableTimes.tsxindex 89d7436f2a8..c9a1c97cc8c 100644--- a/packages/features/bookings/components/AvailableTimes.tsx+++ b/packages/features/bookings/components/AvailableTimes.tsx@@ -3,6 +3,7 @@ import * as HoverCard from "@radix-ui/react-hover-card";import { AnimatePresence, m } from "framer-motion";import { useMemo } from "react";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";import dayjs from "@calcom/dayjs";import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";@@ -10,7 +11,6 @@ import { OutOfOfficeInSlots } from "@calcom/features/bookings/Booker/components/import type { IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";import type { BookerEvent } from "@calcom/features/bookings/types";import type { Slot } from "@calcom/features/schedules/lib/use-schedule/types";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import type { IOutOfOfficeData } from "@calcom/lib/getUserAvailability";import { useLocale } from "@calcom/lib/hooks/useLocale";import { localStorage } from "@calcom/lib/webstorage";diff --git a/packages/features/bookings/components/event-meta/Details.tsx b/packages/features/bookings/components/event-meta/Details.tsxindex 1a0be5ef77e..ccce8cc9c0f 100644--- a/packages/features/bookings/components/event-meta/Details.tsx+++ b/packages/features/bookings/components/event-meta/Details.tsx@@ -1,9 +1,9 @@import React, { Fragment } from "react";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { useBookerStore } from "@calcom/features/bookings/Booker/store";import { PriceIcon } from "@calcom/features/bookings/components/event-meta/PriceIcon";import type { BookerEvent } from "@calcom/features/bookings/types";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useLocale } from "@calcom/lib/hooks/useLocale";import classNames from "@calcom/ui/classNames";import { Icon } from "@calcom/ui/components/icon";diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.tsindex 92dc9f4c0e5..79e76e31aca 100644--- a/packages/features/bookings/lib/handleCancelBooking.ts+++ b/packages/features/bookings/lib/handleCancelBooking.ts@@ -6,6 +6,8 @@ import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utilimport dayjs from "@calcom/dayjs";import { sendCancelledEmailsAndSMS } from "@calcom/emails";import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";+import { processNoShowFeeOnCancellation } from "@calcom/features/bookings/lib/payment/processNoShowFeeOnCancellation";+import { processPaymentRefund } from "@calcom/features/bookings/lib/payment/processPaymentRefund";import { sendCancelledReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";import type { GetSubscriberOptions } from "@calcom/features/webhooks/lib/getWebhooks";import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks";@@ -23,8 +25,6 @@ import { HttpError } from "@calcom/lib/http-error";import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj";import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";import logger from "@calcom/lib/logger";-import { processNoShowFeeOnCancellation } from "@calcom/lib/payment/processNoShowFeeOnCancellation";-import { processPaymentRefund } from "@calcom/lib/payment/processPaymentRefund";import { safeStringify } from "@calcom/lib/safeStringify";import { getTranslation } from "@calcom/lib/server/i18n";import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";diff --git a/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts b/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.tsindex 0ad54ff65d0..a99278e8def 100644--- a/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts+++ b/packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts@@ -18,11 +18,11 @@ import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAnimport { describe, expect, vi } from "vitest";-import { processPaymentRefund } from "@calcom/lib/payment/processPaymentRefund";+import { processPaymentRefund } from "@calcom/features/bookings/lib/payment/processPaymentRefund";import { BookingStatus } from "@calcom/prisma/enums";import { test } from "@calcom/web/test/fixtures/fixtures";-vi.mock("@calcom/lib/payment/processPaymentRefund", () => ({+vi.mock("@calcom/features/bookings/lib/payment/processPaymentRefund", () => ({processPaymentRefund: vi.fn(),}));diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.tsindex 97ee75a97df..f8aadd9f464 100644--- a/packages/features/bookings/lib/handleNewBooking.ts+++ b/packages/features/bookings/lib/handleNewBooking.ts@@ -54,7 +54,7 @@ import { getErrorFromUnknown } from "@calcom/lib/errors";import { extractBaseEmail } from "@calcom/lib/extract-base-email";import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";import { HttpError } from "@calcom/lib/http-error";import type { CheckBookingLimitsService } from "@calcom/lib/intervalLimits/server/checkBookingLimits";diff --git a/packages/features/bookings/lib/handleNewBooking/types.ts b/packages/features/bookings/lib/handleNewBooking/types.tsindex 26d2a4e6c2b..2cc05361c14 100644--- a/packages/features/bookings/lib/handleNewBooking/types.ts+++ b/packages/features/bookings/lib/handleNewBooking/types.ts@@ -1,7 +1,7 @@import type { TFunction } from "i18next";+import type { PaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import type { EventTypeAppsList } from "@calcom/app-store/utils";-import type { PaymentAppData } from "@calcom/lib/getPaymentAppData";import type { GetUserAvailabilityResult } from "@calcom/lib/getUserAvailability";import type { userSelect } from "@calcom/prisma";import type { App } from "@calcom/prisma/client";diff --git a/packages/lib/payment/deletePayment.ts b/packages/features/bookings/lib/payment/deletePayment.tssimilarity index 100%rename from packages/lib/payment/deletePayment.tsrename to packages/features/bookings/lib/payment/deletePayment.tsdiff --git a/packages/lib/payment/getBooking.ts b/packages/features/bookings/lib/payment/getBooking.tssimilarity index 97%rename from packages/lib/payment/getBooking.tsrename to packages/features/bookings/lib/payment/getBooking.tsindex 877c848d0fa..9a81952b397 100644--- a/packages/lib/payment/getBooking.ts+++ b/packages/features/bookings/lib/payment/getBooking.ts@@ -1,5 +1,7 @@import { workflowSelect } from "@calcom/ee/workflows/lib/getAllWorkflows";import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";+import { enrichUserWithDelegationCredentials } from "@calcom/lib/delegationCredential/server";+import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";import { HttpError as HttpCode } from "@calcom/lib/http-error";import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj";import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";@@ -10,9 +12,6 @@ import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credeimport { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";import type { CalendarEvent } from "@calcom/types/Calendar";-import { enrichUserWithDelegationCredentials } from "../delegationCredential/server";-import { getBookerBaseUrl } from "../getBookerUrl/server";-async function getEventType(id: number) {return prisma.eventType.findUnique({where: {diff --git a/packages/lib/payment/handleNoShowFee.test.ts b/packages/features/bookings/lib/payment/handleNoShowFee.test.tssimilarity index 100%rename from packages/lib/payment/handleNoShowFee.test.tsrename to packages/features/bookings/lib/payment/handleNoShowFee.test.tsdiff --git a/packages/lib/payment/handleNoShowFee.ts b/packages/features/bookings/lib/payment/handleNoShowFee.tssimilarity index 100%rename from packages/lib/payment/handleNoShowFee.tsrename to packages/features/bookings/lib/payment/handleNoShowFee.tsdiff --git a/packages/lib/payment/handlePaymentRefund.ts b/packages/features/bookings/lib/payment/handlePaymentRefund.tssimilarity index 100%rename from packages/lib/payment/handlePaymentRefund.tsrename to packages/features/bookings/lib/payment/handlePaymentRefund.tsdiff --git a/packages/lib/payment/handleRefundError.ts b/packages/features/bookings/lib/payment/handleRefundError.tssimilarity index 100%rename from packages/lib/payment/handleRefundError.tsrename to packages/features/bookings/lib/payment/handleRefundError.tsdiff --git a/packages/lib/payment/processNoShowFeeOnCancellation.test.ts b/packages/features/bookings/lib/payment/processNoShowFeeOnCancellation.test.tssimilarity index 100%rename from packages/lib/payment/processNoShowFeeOnCancellation.test.tsrename to packages/features/bookings/lib/payment/processNoShowFeeOnCancellation.test.tsdiff --git a/packages/lib/payment/processNoShowFeeOnCancellation.ts b/packages/features/bookings/lib/payment/processNoShowFeeOnCancellation.tssimilarity index 100%rename from packages/lib/payment/processNoShowFeeOnCancellation.tsrename to packages/features/bookings/lib/payment/processNoShowFeeOnCancellation.tsdiff --git a/packages/lib/payment/processPaymentRefund.test.ts b/packages/features/bookings/lib/payment/processPaymentRefund.test.tssimilarity index 62%rename from packages/lib/payment/processPaymentRefund.test.tsrename to packages/features/bookings/lib/payment/processPaymentRefund.test.tsindex e0800bcac36..ce59e666a75 100644--- a/packages/lib/payment/processPaymentRefund.test.ts+++ b/packages/features/bookings/lib/payment/processPaymentRefund.test.ts@@ -1,22 +1,24 @@-import prismaMock from "../../../tests/libs/__mocks__/prismaMock";+import prismock from "../../../../../tests/libs/__mocks__/prisma";import { describe, it, expect, vi, beforeEach } from "vitest";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import dayjs from "@calcom/dayjs";+import { RefundPolicy } from "@calcom/lib/payment/types";-import { getPaymentAppData } from "../getPaymentAppData";import { handlePaymentRefund } from "./handlePaymentRefund";import { processPaymentRefund } from "./processPaymentRefund";-import { RefundPolicy } from "./types";-vi.mock("@calcom/lib/getPaymentAppData", () => ({+vi.mock("@calcom/app-store/_utils/payments/getPaymentAppData", () => ({getPaymentAppData: vi.fn(),}));-vi.mock("@calcom/lib/payment/handlePaymentRefund", () => ({+vi.mock("./handlePaymentRefund", () => ({handlePaymentRefund: vi.fn(),}));+const mockedGetPaymentAppData = vi.mocked(getPaymentAppData);+describe("processPaymentRefund", () => {const mockStartTime = new Date("2025-01-01T10:00:00Z");@@ -53,19 +55,29 @@ describe("processPaymentRefund", () => {refundDaysCount: 3,};- const mockPaymentAppCredentials = [- {- key: "key1",- appId: "123",- app: {- categories: ["category1"],- dirName: "app1",- },- },- ];+ const mockApp = {+ id: "123",+ slug: "stripe",+ dirName: "app1",+ categories: ["payment"],+ keys: {},+ enabled: true,+ };++ const mockCredential = {+ id: 1,+ key: "key1",+ appId: "123",+ userId: 1,+ teamId: null,+ type: "stripe_payment",+ invalid: false,+ };- beforeEach(() => {+ beforeEach(async () => {vi.clearAllMocks();+ await prismock.credential.deleteMany();+ await prismock.app.deleteMany();});it("should not process refund if no teamId or eventType owner", async () => {@@ -80,14 +92,15 @@ describe("processPaymentRefund", () => {});it("should not process refund if refund policy is NEVER", async () => {- (getPaymentAppData as any).mockReturnValueOnce({ ...mockAppData, refundPolicy: RefundPolicy.NEVER });+ mockedGetPaymentAppData.mockReturnValueOnce({ ...mockAppData, refundPolicy: RefundPolicy.NEVER });await processPaymentRefund({ booking: mockBooking, teamId: 1 });expect(handlePaymentRefund).not.toHaveBeenCalled();});it("should process refund if refund policy is DAYS and within refund window", async () => {- (getPaymentAppData as any).mockReturnValueOnce(mockAppData);- prismaMock.credential.findMany.mockResolvedValueOnce(mockPaymentAppCredentials);+ mockedGetPaymentAppData.mockReturnValueOnce(mockAppData);+ await prismock.app.create({ data: mockApp });+ await prismock.credential.create({ data: mockCredential });const mockNow = dayjs(mockStartTime).subtract(8, "days").toDate();vi.useFakeTimers();@@ -95,12 +108,19 @@ describe("processPaymentRefund", () => {await processPaymentRefund({ booking: mockBooking, teamId: 1 });- expect(handlePaymentRefund).toHaveBeenCalledWith(1, mockPaymentAppCredentials[0]);+ expect(handlePaymentRefund).toHaveBeenCalledWith(+ 1,+ expect.objectContaining({+ key: "key1",+ appId: "123",+ })+ );});it("should not process refund if past the refund deadline", async () => {- (getPaymentAppData as any).mockReturnValueOnce(mockAppData);- prismaMock.credential.findMany.mockResolvedValueOnce(mockPaymentAppCredentials);+ mockedGetPaymentAppData.mockReturnValueOnce(mockAppData);+ await prismock.app.create({ data: mockApp });+ await prismock.credential.create({ data: mockCredential });const mockNow = dayjs(mockStartTime).subtract(2, "days").toDate();@@ -113,8 +133,9 @@ describe("processPaymentRefund", () => {});it("should process refund if business days are considered and before deadline", async () => {- (getPaymentAppData as any).mockReturnValueOnce({ ...mockAppData, refundCountCalendarDays: false });- prismaMock.credential.findMany.mockResolvedValueOnce(mockPaymentAppCredentials);+ mockedGetPaymentAppData.mockReturnValueOnce({ ...mockAppData, refundCountCalendarDays: false });+ await prismock.app.create({ data: mockApp });+ await prismock.credential.create({ data: mockCredential });// eslint-disable-next-line @typescript-eslint/ban-ts-comment//@ts-ignore@@ -125,12 +146,19 @@ describe("processPaymentRefund", () => {await processPaymentRefund({ booking: mockBooking, teamId: 1 });- expect(handlePaymentRefund).toHaveBeenCalledWith(1, mockPaymentAppCredentials[0]);+ expect(handlePaymentRefund).toHaveBeenCalledWith(+ 1,+ expect.objectContaining({+ key: "key1",+ appId: "123",+ })+ );});it("should not process refund if business days are considered and after deadline", async () => {- (getPaymentAppData as any).mockReturnValueOnce({ ...mockAppData, refundCountCalendarDays: false });- prismaMock.credential.findMany.mockResolvedValueOnce(mockPaymentAppCredentials);+ mockedGetPaymentAppData.mockReturnValueOnce({ ...mockAppData, refundCountCalendarDays: false });+ await prismock.app.create({ data: mockApp });+ await prismock.credential.create({ data: mockCredential });const mockNow = dayjs(mockStartTime).subtract(3, "days").toDate();@@ -143,8 +171,7 @@ describe("processPaymentRefund", () => {});it("should not process refund if paymentAppCredential is not found", async () => {- (getPaymentAppData as any).mockReturnValueOnce(mockAppData);- prismaMock.credential.findMany.mockResolvedValueOnce([]);+ mockedGetPaymentAppData.mockReturnValueOnce(mockAppData);await processPaymentRefund({ booking: mockBooking, teamId: 1 });expect(handlePaymentRefund).not.toHaveBeenCalled();diff --git a/packages/lib/payment/processPaymentRefund.ts b/packages/features/bookings/lib/payment/processPaymentRefund.tssimilarity index 91%rename from packages/lib/payment/processPaymentRefund.tsrename to packages/features/bookings/lib/payment/processPaymentRefund.tsindex 095cca042c9..cb7d1935c35 100644--- a/packages/lib/payment/processPaymentRefund.ts+++ b/packages/features/bookings/lib/payment/processPaymentRefund.ts@@ -1,12 +1,11 @@+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import dayjs from "@calcom/dayjs";+import { handlePaymentRefund } from "@calcom/features/bookings/lib/payment/handlePaymentRefund";+import { RefundPolicy } from "@calcom/lib/payment/types";import prisma from "@calcom/prisma";import type { Payment, Prisma } from "@calcom/prisma/client";import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";-import { getPaymentAppData } from "../getPaymentAppData";-import { handlePaymentRefund } from "./handlePaymentRefund";-import { RefundPolicy } from "./types";-export const processPaymentRefund = async ({booking,teamId,diff --git a/packages/lib/payment/shouldChargeNoShowCancellationFee.test.ts b/packages/features/bookings/lib/payment/shouldChargeNoShowCancellationFee.test.tssimilarity index 100%rename from packages/lib/payment/shouldChargeNoShowCancellationFee.test.tsrename to packages/features/bookings/lib/payment/shouldChargeNoShowCancellationFee.test.tsdiff --git a/packages/lib/payment/shouldChargeNoShowCancellationFee.ts b/packages/features/bookings/lib/payment/shouldChargeNoShowCancellationFee.tssimilarity index 100%rename from packages/lib/payment/shouldChargeNoShowCancellationFee.tsrename to packages/features/bookings/lib/payment/shouldChargeNoShowCancellationFee.tsdiff --git a/packages/features/credentials/handleDeleteCredential.ts b/packages/features/credentials/handleDeleteCredential.tsindex 6111aaced3b..66963ba2459 100644--- a/packages/features/credentials/handleDeleteCredential.ts+++ b/packages/features/credentials/handleDeleteCredential.ts@@ -9,12 +9,12 @@ import {import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";import { sendCancelledEmailsAndSMS } from "@calcom/emails";import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";+import { deletePayment } from "@calcom/features/bookings/lib/payment/deletePayment";import { deleteWebhookScheduledTriggers } from "@calcom/features/webhooks/lib/scheduleTrigger";import { buildNonDelegationCredential } from "@calcom/lib/delegationCredential/server";import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj";import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";import { DailyLocationType } from "@calcom/lib/location";-import { deletePayment } from "@calcom/lib/payment/deletePayment";import { getTranslation } from "@calcom/lib/server/i18n";import { bookingMinimalSelect, prisma } from "@calcom/prisma";import type { Prisma } from "@calcom/prisma/client";diff --git a/packages/features/ee/payments/api/webhook.ts b/packages/features/ee/payments/api/webhook.tsindex 40ef94a325b..65aec9de056 100644--- a/packages/features/ee/payments/api/webhook.ts+++ b/packages/features/ee/payments/api/webhook.ts@@ -8,6 +8,7 @@ import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcimport { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation";import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";+import { getBooking } from "@calcom/features/bookings/lib/payment/getBooking";import stripe from "@calcom/features/ee/payments/server/stripe";import { getPlatformParams } from "@calcom/features/platform-oauth-client/get-platform-params";import { PlatformOAuthClientRepository } from "@calcom/features/platform-oauth-client/platform-oauth-client.repository";@@ -16,7 +17,6 @@ import { IS_PRODUCTION } from "@calcom/lib/constants";import { getErrorFromUnknown } from "@calcom/lib/errors";import { HttpError as HttpCode } from "@calcom/lib/http-error";import logger from "@calcom/lib/logger";-import { getBooking } from "@calcom/lib/payment/getBooking";import { safeStringify } from "@calcom/lib/safeStringify";import { prisma } from "@calcom/prisma";import type { Prisma } from "@calcom/prisma/client";diff --git a/packages/features/eventtypes/components/EventTypeDescription.tsx b/packages/features/eventtypes/components/EventTypeDescription.tsxindex e01835b38a4..1e645917400 100644--- a/packages/features/eventtypes/components/EventTypeDescription.tsx+++ b/packages/features/eventtypes/components/EventTypeDescription.tsx@@ -1,9 +1,9 @@import { useMemo } from "react";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";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";import { useLocale } from "@calcom/lib/hooks/useLocale";import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";diff --git a/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx b/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsxindex 99318ab73ad..18550c8be7a 100644--- a/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx+++ b/packages/features/eventtypes/components/tabs/instant/EventInstantTab.tsx@@ -1,6 +1,6 @@+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";import type { EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import InstantEventController from "./InstantEventController";diff --git a/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx b/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsxindex b13d1387cff..1bd636945c0 100644--- a/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx+++ b/packages/features/eventtypes/components/tabs/recurring/EventRecurringTab.tsx@@ -1,5 +1,5 @@+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import type { RecurringEventControllerProps } from "./RecurringEventController";import RecurringEventController from "./RecurringEventController";diff --git a/packages/platform/atoms/event-types/hooks/usePlatformTabsNavigations.tsx b/packages/platform/atoms/event-types/hooks/usePlatformTabsNavigations.tsxindex 28498d022a9..e323bf4eefe 100644--- a/packages/platform/atoms/event-types/hooks/usePlatformTabsNavigations.tsx+++ b/packages/platform/atoms/event-types/hooks/usePlatformTabsNavigations.tsx@@ -6,9 +6,9 @@ import type { TFunction } from "i18next";import { useMemo, useState, useEffect } from "react";import type { UseFormReturn } from "react-hook-form";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";import type { EventTypeSetupProps, FormValues } from "@calcom/features/eventtypes/lib/types";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useLocale } from "@calcom/lib/hooks/useLocale";import type { VerticalTabItemProps } from "@calcom/ui/components/navigation";diff --git a/packages/platform/atoms/event-types/hooks/useTabsNavigations.tsx b/packages/platform/atoms/event-types/hooks/useTabsNavigations.tsxindex 6dec69eeeee..c36cbaaefc8 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 { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";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";@@ -14,7 +15,6 @@ import type {FormValues,EventTypeApps,} from "@calcom/features/eventtypes/lib/types";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useLocale } from "@calcom/lib/hooks/useLocale";import type { VerticalTabItemProps } from "@calcom/ui/components/navigation";diff --git a/packages/platform/atoms/event-types/payments/PaymentForm.tsx b/packages/platform/atoms/event-types/payments/PaymentForm.tsxindex e1ede706215..78fb19f2659 100644--- a/packages/platform/atoms/event-types/payments/PaymentForm.tsx+++ b/packages/platform/atoms/event-types/payments/PaymentForm.tsx@@ -1,12 +1,12 @@import React, { Suspense } from "react";+import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";import { getSuccessPageLocationMessage } from "@calcom/app-store/locations";import dayjs from "@calcom/dayjs";import { PayIcon } from "@calcom/features/bookings/components/event-meta/PayIcon";import { Price } from "@calcom/features/bookings/components/event-meta/Price";import type { PaymentPageProps } from "@calcom/features/ee/payments/pages/payment";import { APP_NAME, WEBSITE_URL } from "@calcom/lib/constants";-import { getPaymentAppData } from "@calcom/lib/getPaymentAppData";import { useLocale } from "@calcom/lib/hooks/useLocale";import { isBrowserLocale24h } from "@calcom/lib/timeFormat";import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants";diff --git a/packages/platform/libraries/app-store.ts b/packages/platform/libraries/app-store.tsindex 7912bd1f126..71e8764c8fc 100644--- a/packages/platform/libraries/app-store.ts+++ b/packages/platform/libraries/app-store.ts@@ -1,6 +1,6 @@+import getEnabledAppsFromCredentials from "@calcom/app-store/_utils/getEnabledAppsFromCredentials";import getApps from "@calcom/app-store/utils";import handleDeleteCredential from "@calcom/features/credentials/handleDeleteCredential";-import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";import addDelegationCredential from "@calcom/trpc/server/routers/viewer/delegationCredential/add.handler";export type { TDependencyData } from "@calcom/app-store/_appRegistry";diff --git a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts b/packages/trpc/server/routers/viewer/bookings/confirm.handler.tsindex 86228e6e507..fe32c113f6d 100644--- a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts+++ b/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts@@ -5,6 +5,7 @@ import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookimport { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";+import { processPaymentRefund } from "@calcom/features/bookings/lib/payment/processPaymentRefund";import { workflowSelect } from "@calcom/features/ee/workflows/lib/getAllWorkflows";import type { GetSubscriberOptions } from "@calcom/features/webhooks/lib/getWebhooks";import type { EventPayloadType, EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";@@ -13,7 +14,6 @@ import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj";import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";-import { processPaymentRefund } from "@calcom/lib/payment/processPaymentRefund";import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials";import { getTranslation } from "@calcom/lib/server/i18n";import { WorkflowService } from "@calcom/lib/server/service/workflows";diff --git a/packages/trpc/server/routers/viewer/payments/chargeCard.handler.ts b/packages/trpc/server/routers/viewer/payments/chargeCard.handler.tsindex 2f2bb1d0051..f221cd0d9af 100644--- a/packages/trpc/server/routers/viewer/payments/chargeCard.handler.ts+++ b/packages/trpc/server/routers/viewer/payments/chargeCard.handler.ts@@ -1,4 +1,4 @@-import { handleNoShowFee } from "@calcom/lib/payment/handleNoShowFee";+import { handleNoShowFee } from "@calcom/features/bookings/lib/payment/handleNoShowFee";import { BookingRepository } from "@calcom/lib/server/repository/booking";import type { PrismaClient } from "@calcom/prisma";diff --git a/yarn.lock b/yarn.lockindex 1db0bafde66..8e20d4e43f2 100644--- a/yarn.lock+++ b/yarn.lock@@ -2715,7 +2715,7 @@ __metadata:"@axiomhq/winston": ^1.2.0"@calcom/platform-constants": "*""@calcom/platform-enums": "*"- "@calcom/platform-libraries": "npm:@calcom/[email protected]"+ "@calcom/platform-libraries": "npm:@calcom/[email protected]""@calcom/platform-types": "*""@calcom/platform-utils": "*""@calcom/prisma": "*"@@ -3775,13 +3775,13 @@ __metadata:languageName: unknownlinkType: soft-"@calcom/platform-libraries@npm:@calcom/[email protected]":- version: 0.0.358- resolution: "@calcom/platform-libraries@npm:0.0.358"+"@calcom/platform-libraries@npm:@calcom/[email protected]":+ version: 0.0.359+ resolution: "@calcom/platform-libraries@npm:0.0.359"dependencies:"@calcom/features": "*""@calcom/lib": "*"- checksum: 2a3436a24c62c38aa1299237cc2c650826a3cfc9cbffa5cc2f37244abed13dc0f55dbd314037e16af3168b9e7bfa4b62abf20aee00654e8aa24ab4bc7e76c642+ checksum: 265d73c95334e34d076406d943ba6e80cff0037b4cf4620ed86519d41ac8e24e643000b84773c1f17cece28c4f50bd1cd70a0306764908248a55af49b44f054flanguageName: nodelinkType: hard