diff --git a/apps/api/v1/pages/api/connected-calendars/_get.ts b/apps/api/v1/pages/api/connected-calendars/_get.ts index d8cb6835a5..9329281a27 100644 --- a/apps/api/v1/pages/api/connected-calendars/_get.ts +++ b/apps/api/v1/pages/api/connected-calendars/_get.ts @@ -1,7 +1,7 @@ import type { NextApiRequest } from "next"; -import type { UserWithCalendars } from "@calcom/lib/getConnectedDestinationCalendars"; -import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars"; +import type { UserWithCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; +import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; import { HttpError } from "@calcom/lib/http-error"; import { defaultResponder } from "@calcom/lib/server/defaultResponder"; import { UserRepository } from "@calcom/lib/server/repository/user"; diff --git a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RouteBuilder.tsx b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RouteBuilder.tsx index 2bc7ccfd12..21142e225d 100644 --- a/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RouteBuilder.tsx +++ b/apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RouteBuilder.tsx @@ -10,6 +10,7 @@ import type { UseFormReturn } from "react-hook-form"; import { Toaster } from "sonner"; import type { z } from "zod"; +import { buildEmptyQueryValue, raqbQueryValueUtils } from "@calcom/app-store/_utils/raqb/raqbUtils"; import { routingFormAppComponents } from "@calcom/app-store/routing-forms/appComponents"; import DynamicAppComponent from "@calcom/app-store/routing-forms/components/DynamicAppComponent"; import { EmptyState } from "@calcom/app-store/routing-forms/components/_components/EmptyState"; @@ -44,7 +45,6 @@ import { useOrgBranding } from "@calcom/features/ee/organizations/context/provid import type { EventTypesByViewer } from "@calcom/features/eventtypes/lib/getEventTypesByViewer"; import { areTheySiblingEntities } from "@calcom/lib/entityPermissionUtils.shared"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { buildEmptyQueryValue, raqbQueryValueUtils } from "@calcom/lib/raqb/raqbUtils"; import type { Prisma } from "@calcom/prisma/client"; import { SchedulingType } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; @@ -1190,7 +1190,7 @@ const Routes = ({ }) || []; // const isConnectedForm = (id: string) => form.connectedForms.map((f) => f.id).includes(id); - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // const routers: any[] = []; /* Disable this feature for new forms till we get it fully working with Routing Form with Attributes. This isn't much used feature */ // const routers = availableRouters.map((r) => { @@ -1235,7 +1235,7 @@ const Routes = ({ }); setRoutes((routes) => { // Even though it's obvious that fallbackRoute is defined here but TypeScript just can't figure it out. - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return [...routes, fallbackRoute!]; }); return null; @@ -1243,7 +1243,7 @@ const Routes = ({ // Ensure fallback is last setRoutes((routes) => { // Even though it's obvious that fallbackRoute is defined here but TypeScript just can't figure it out. - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return [...routes.filter((route) => route.id !== fallbackRoute!.id), fallbackRoute!]; }); } diff --git a/apps/web/app/api/cron/selected-calendars/route.ts b/apps/web/app/api/cron/selected-calendars/route.ts index e015b31f1c..b311a63dbe 100644 --- a/apps/web/app/api/cron/selected-calendars/route.ts +++ b/apps/web/app/api/cron/selected-calendars/route.ts @@ -8,7 +8,7 @@ import { NextResponse } from "next/server"; import GoogleCalendarService from "@calcom/app-store/googlecalendar/lib/CalendarService"; import { CalendarAppDelegationCredentialInvalidGrantError } from "@calcom/lib/CalendarAppError"; -import { findUniqueDelegationCalendarCredential } from "@calcom/lib/delegationCredential/server"; +import { findUniqueDelegationCalendarCredential } from "@calcom/app-store/delegationCredential"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; diff --git a/packages/app-store/_appRegistry.ts b/packages/app-store/_appRegistry.ts index 202045df33..439b69e736 100644 --- a/packages/app-store/_appRegistry.ts +++ b/packages/app-store/_appRegistry.ts @@ -1,7 +1,7 @@ import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData"; import { getAppFromSlug } from "@calcom/app-store/utils"; +import { getAllDelegationCredentialsForUser } from "@calcom/app-store/delegationCredential"; import getInstallCountPerApp from "@calcom/lib/apps/getInstallCountPerApp"; -import { getAllDelegationCredentialsForUser } from "@calcom/lib/delegationCredential/server"; import type { UserAdminTeams } from "@calcom/lib/server/repository/user"; import prisma, { safeAppSelect, safeCredentialSelect } from "@calcom/prisma"; import { userMetadata } from "@calcom/prisma/zod-utils"; diff --git a/packages/app-store/_utils/CRMRoundRobinSkip.ts b/packages/app-store/_utils/CRMRoundRobinSkip.ts index 683ce1f8af..2e6b8e92c6 100644 --- a/packages/app-store/_utils/CRMRoundRobinSkip.ts +++ b/packages/app-store/_utils/CRMRoundRobinSkip.ts @@ -1,7 +1,7 @@ import type { z } from "zod"; import type { EventTypeAppMetadataSchema } from "@calcom/app-store/zod-utils"; -import CrmManager from "@calcom/lib/crmManager/crmManager"; +import CrmManager from "@calcom/features/crmManager/crmManager"; import logger from "@calcom/lib/logger"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; diff --git a/packages/app-store/_utils/getConnectedApps.ts b/packages/app-store/_utils/getConnectedApps.ts index fdbe187bfa..fba006c2d1 100644 --- a/packages/app-store/_utils/getConnectedApps.ts +++ b/packages/app-store/_utils/getConnectedApps.ts @@ -1,7 +1,7 @@ +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner"; import getInstallCountPerApp from "@calcom/lib/apps/getInstallCountPerApp"; -import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential/clientAndServer"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; +import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; import type { PrismaClient } from "@calcom/prisma"; import type { Prisma, User, AppCategories } from "@calcom/prisma/client"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; diff --git a/packages/app-store/_utils/getDefaultLocations.ts b/packages/app-store/_utils/getDefaultLocations.ts index 369ca8afcd..b2f416abee 100644 --- a/packages/app-store/_utils/getDefaultLocations.ts +++ b/packages/app-store/_utils/getDefaultLocations.ts @@ -1,6 +1,6 @@ import type { z } from "zod"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import type { Prisma } from "@calcom/prisma/client"; import { userMetadata as userMetadataSchema, type eventTypeLocations } from "@calcom/prisma/zod-utils"; diff --git a/packages/app-store/_utils/getEnabledAppsFromCredentials.ts b/packages/app-store/_utils/getEnabledAppsFromCredentials.ts index 5148b47eff..a9e84a941f 100644 --- a/packages/app-store/_utils/getEnabledAppsFromCredentials.ts +++ b/packages/app-store/_utils/getEnabledAppsFromCredentials.ts @@ -1,5 +1,5 @@ import type { CredentialDataWithTeamName } from "@calcom/app-store/utils"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; diff --git a/packages/app-store/_utils/oauth/getCurrentTokenObject.ts b/packages/app-store/_utils/oauth/getCurrentTokenObject.ts index 613f91ff19..1e6110bf36 100644 --- a/packages/app-store/_utils/oauth/getCurrentTokenObject.ts +++ b/packages/app-store/_utils/oauth/getCurrentTokenObject.ts @@ -1,4 +1,4 @@ -import { isInMemoryDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; +import { isInMemoryDelegationCredential } from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; import { CredentialRepository } from "@calcom/lib/server/repository/credential"; import type { CredentialForCalendarService } from "@calcom/types/Credential"; diff --git a/packages/lib/raqb/findTeamMembersMatchingAttributeLogic.test.ts b/packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.test.ts similarity index 99% rename from packages/lib/raqb/findTeamMembersMatchingAttributeLogic.test.ts rename to packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.test.ts index 9bafeb23e5..6310626a02 100644 --- a/packages/lib/raqb/findTeamMembersMatchingAttributeLogic.test.ts +++ b/packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.test.ts @@ -6,7 +6,7 @@ import { RaqbLogicResult } from "@calcom/lib/raqb/evaluateRaqbLogic"; import { findTeamMembersMatchingAttributeLogic, TroubleshooterCase, -} from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +} from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; import * as getAttributesModule from "@calcom/lib/service/attribute/server/getAttributes"; import type { AttributeType } from "@calcom/prisma/enums"; import { RoutingFormFieldType } from "@calcom/routing-forms/lib/FieldTypes"; @@ -18,7 +18,7 @@ vi.mock("@calcom/lib/service/attribute/server/getAttributes", () => { }; }); -vi.mock("../../components/react-awesome-query-builder/widgets", () => ({ +vi.mock("@calcom/app-store/routing-forms/components/react-awesome-query-builder/widgets", () => ({ default: {}, })); @@ -64,13 +64,13 @@ function mockAttributesScenario({ Object.entries(member.attributes).map(([attributeId, value]) => { return [ attributeId, - // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain + { attributeOption: value instanceof Array ? value.map((value) => ({ value, isGroup: false, contains: [] })) : { value, isGroup: false, contains: [] }, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + type: attributes.find((attribute) => attribute.id === attributeId)!.type, }, ]; diff --git a/packages/lib/raqb/findTeamMembersMatchingAttributeLogic.ts b/packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.ts similarity index 98% rename from packages/lib/raqb/findTeamMembersMatchingAttributeLogic.ts rename to packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.ts index ee91db434a..15de66d9ff 100644 --- a/packages/lib/raqb/findTeamMembersMatchingAttributeLogic.ts +++ b/packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.ts @@ -3,14 +3,13 @@ import type { ImmutableTree, JsonLogicResult, JsonTree } from "react-awesome-que import type { Config } from "react-awesome-query-builder/lib"; import { Utils as QbUtils } from "react-awesome-query-builder/lib"; -import type { dynamicFieldValueOperands } from "@calcom/lib/raqb/types"; +import { RaqbLogicResult } from "@calcom/lib/raqb/evaluateRaqbLogic"; +import jsonLogic from "@calcom/lib/raqb/jsonLogic"; +import type { dynamicFieldValueOperands, AttributesQueryValue } from "@calcom/lib/raqb/types"; import { getAttributesAssignmentData } from "@calcom/lib/service/attribute/server/getAttributes"; import type { Attribute } from "@calcom/lib/service/attribute/server/getAttributes"; -import { RaqbLogicResult } from "./evaluateRaqbLogic"; -import jsonLogic from "./jsonLogic"; import { acrossQueryValueCompatiblity, raqbQueryValueUtils } from "./raqbUtils"; -import type { AttributesQueryValue } from "./types"; const { getAttributesData: getAttributes, diff --git a/packages/lib/raqb/raqbUtils.test.ts b/packages/app-store/_utils/raqb/raqbUtils.test.ts similarity index 100% rename from packages/lib/raqb/raqbUtils.test.ts rename to packages/app-store/_utils/raqb/raqbUtils.test.ts diff --git a/packages/lib/raqb/raqbUtils.ts b/packages/app-store/_utils/raqb/raqbUtils.ts similarity index 98% rename from packages/lib/raqb/raqbUtils.ts rename to packages/app-store/_utils/raqb/raqbUtils.ts index d6fdbfd620..66556cd451 100644 --- a/packages/lib/raqb/raqbUtils.ts +++ b/packages/app-store/_utils/raqb/raqbUtils.ts @@ -4,7 +4,9 @@ import { Utils as QbUtils } from "react-awesome-query-builder"; import { getQueryBuilderConfigForAttributes } from "@calcom/app-store/routing-forms/lib/getQueryBuilderConfig"; import type { LocalRoute } from "@calcom/app-store/routing-forms/types/types"; +import { resolveQueryValue } from "@calcom/lib/raqb/resolveQueryValue"; import type { dynamicFieldValueOperands } from "@calcom/lib/raqb/types"; +import { caseInsensitive } from "@calcom/lib/raqb/utils"; import { safeStringify } from "@calcom/lib/safeStringify"; import type { AttributeOptionValueWithType, @@ -13,9 +15,6 @@ import type { } from "@calcom/lib/service/attribute/server/getAttributes"; import { AttributeType } from "@calcom/prisma/enums"; -import { resolveQueryValue } from "./resolveQueryValue"; -import { caseInsensitive } from "./utils"; - function ensureArray(value: string | string[]) { return typeof value === "string" ? [value] : value; } diff --git a/packages/lib/delegationCredential/server.test.ts b/packages/app-store/delegationCredential.test.ts similarity index 98% rename from packages/lib/delegationCredential/server.test.ts rename to packages/app-store/delegationCredential.test.ts index b495cecf27..26ecbb1b21 100644 --- a/packages/lib/delegationCredential/server.test.ts +++ b/packages/app-store/delegationCredential.test.ts @@ -7,7 +7,7 @@ import { metadata as googleMeetMetadata } from "@calcom/app-store/googlevideo/_m import type { ServiceAccountKey } from "@calcom/lib/server/repository/delegationCredential"; import { DelegationCredentialRepository } from "@calcom/lib/server/repository/delegationCredential"; import { OrganizationRepository } from "@calcom/lib/server/repository/organization"; -import { SMSLockState } from "@calcom/prisma/enums"; +import { SMSLockState, RRTimestampBasis } from "@calcom/prisma/enums"; import type { CredentialForCalendarService, CredentialPayload } from "@calcom/types/Credential"; import { @@ -18,7 +18,7 @@ import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey, enrichUserWithDelegationConferencingCredentialsWithoutOrgId, getAllDelegationCredentialsForUserIncludeServiceAccountKey, -} from "./server"; +} from "./delegationCredential"; // Mock OrganizationRepository vi.mock("@calcom/lib/server/repository/organization", () => ({ @@ -60,6 +60,8 @@ const mockDelegationCredential = { workspacePlatform: mockWorkspacePlatform, createdAt: new Date(), updatedAt: new Date(), + lastEnabledAt: new Date(), + lastDisabledAt: null, }; // Mock organization data @@ -103,6 +105,9 @@ const mockOrganization = { isPlatform: false, createdByOAuthClientId: null, bookingLimits: null, + hideTeamProfileLink: false, + rrResetInterval: null, + rrTimestampBasis: RRTimestampBasis.CREATED_AT, }; // Credential Builders diff --git a/packages/lib/delegationCredential/server.ts b/packages/app-store/delegationCredential.ts similarity index 95% rename from packages/lib/delegationCredential/server.ts rename to packages/app-store/delegationCredential.ts index c470ce71b8..94e89568ac 100644 --- a/packages/lib/delegationCredential/server.ts +++ b/packages/app-store/delegationCredential.ts @@ -3,30 +3,28 @@ import { metadata as googleCalendarMetadata } from "@calcom/app-store/googlecale import { metadata as googleMeetMetadata } from "@calcom/app-store/googlevideo/_metadata"; import { metadata as office365CalendarMetaData } from "@calcom/app-store/office365calendar/_metadata"; import { metadata as office365VideoMetaData } from "@calcom/app-store/office365video/_metadata"; +import { + buildNonDelegationCredential, + buildNonDelegationCredentials, + isDelegationCredential, +} from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; import { CredentialRepository } from "@calcom/lib/server/repository/credential"; import type { ServiceAccountKey } from "@calcom/lib/server/repository/delegationCredential"; import { DelegationCredentialRepository } from "@calcom/lib/server/repository/delegationCredential"; +import { UserRepository } from "@calcom/lib/server/repository/user"; import { prisma } from "@calcom/prisma"; import type { SelectedCalendar } from "@calcom/prisma/client"; +import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; import type { CredentialForCalendarService, CredentialPayload } from "@calcom/types/Credential"; -import { UserRepository } from "../server/repository/user"; -import { - buildNonDelegationCredential, - buildNonDelegationCredentials, - isDelegationCredential, -} from "./clientAndServer"; - -export { buildNonDelegationCredentials, buildNonDelegationCredential } from "./clientAndServer"; - const GOOGLE_WORKSPACE_SLUG = "google"; const OFFICE365_WORKSPACE_SLUG = "office365"; const WORKSPACE_PLATFORM_SLUGS = [GOOGLE_WORKSPACE_SLUG, OFFICE365_WORKSPACE_SLUG] as const; type WORKSPACE_PLATFORM_SLUGS_TYPE = (typeof WORKSPACE_PLATFORM_SLUGS)[number]; -const log = logger.getSubLogger({ prefix: ["lib/delegationCredential/server"] }); +const log = logger.getSubLogger({ prefix: ["app-store/delegationCredential"] }); interface DelegationCredential { id: string; workspacePlatform: { @@ -652,6 +650,36 @@ export async function getCredentialForCalendarCache({ credentialId }: { credenti return credentialForCalendarService; } +/** + * It includes in-memory DelegationCredential credentials as well. + */ +export async function getUsersCredentialsIncludeServiceAccountKey(user: User) { + const credentials = await prisma.credential.findMany({ + where: { + userId: user.id, + }, + select: credentialForCalendarServiceSelect, + orderBy: { + id: "asc", + }, + }); + + const { credentials: allCredentials } = await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({ + user: { + email: user.email, + id: user.id, + credentials, + }, + }); + + return allCredentials; +} + +export async function getUsersCredentials(user: User) { + const credentials = await getUsersCredentialsIncludeServiceAccountKey(user); + return credentials.map(({ delegatedTo: _1, ...rest }) => rest); +} + /** * Find the credential for a selected calendar * @param selectedCalendar diff --git a/packages/app-store/googlecalendar/api/webhook.ts b/packages/app-store/googlecalendar/api/webhook.ts index bf823b07ca..d0cf11bc36 100644 --- a/packages/app-store/googlecalendar/api/webhook.ts +++ b/packages/app-store/googlecalendar/api/webhook.ts @@ -1,6 +1,6 @@ import type { NextApiRequest } from "next"; -import { getCredentialForCalendarCache } from "@calcom/lib/delegationCredential/server"; +import { getCredentialForCalendarCache } from "@calcom/app-store/delegationCredential"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; diff --git a/packages/app-store/routing-forms/lib/handleResponse.test.ts b/packages/app-store/routing-forms/lib/handleResponse.test.ts index 44ef7ea319..f3b329b3c7 100644 --- a/packages/app-store/routing-forms/lib/handleResponse.test.ts +++ b/packages/app-store/routing-forms/lib/handleResponse.test.ts @@ -3,7 +3,7 @@ import { prisma } from "@calcom/prisma/__mocks__/prisma"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +import { findTeamMembersMatchingAttributeLogic } from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; import { RoutingFormResponseRepository } from "@calcom/lib/server/repository/formResponse"; import isRouter from "../lib/isRouter"; @@ -12,7 +12,7 @@ import type { TargetRoutingFormForResponse } from "./formSubmissionUtils"; import { onSubmissionOfFormResponse } from "./formSubmissionUtils"; import { handleResponse } from "./handleResponse"; -vi.mock("@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic", () => ({ +vi.mock("@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic", () => ({ findTeamMembersMatchingAttributeLogic: vi.fn(), })); diff --git a/packages/app-store/routing-forms/lib/handleResponse.ts b/packages/app-store/routing-forms/lib/handleResponse.ts index cd46fe1384..c331f024bf 100644 --- a/packages/app-store/routing-forms/lib/handleResponse.ts +++ b/packages/app-store/routing-forms/lib/handleResponse.ts @@ -3,7 +3,7 @@ import { z } from "zod"; import { emailSchema } from "@calcom/lib/emailSchema"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; -import { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +import { findTeamMembersMatchingAttributeLogic } from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; import { safeStringify } from "@calcom/lib/safeStringify"; import { withReporting } from "@calcom/lib/sentryWrapper"; import { RoutingFormResponseRepository } from "@calcom/lib/server/repository/formResponse"; diff --git a/packages/app-store/salesforce/lib/routingForm/incompleteBookingAction.ts b/packages/app-store/salesforce/lib/routingForm/incompleteBookingAction.ts index 2bc3c21838..ae440c5578 100644 --- a/packages/app-store/salesforce/lib/routingForm/incompleteBookingAction.ts +++ b/packages/app-store/salesforce/lib/routingForm/incompleteBookingAction.ts @@ -1,6 +1,6 @@ +import { CredentialRepository } from "@calcom/lib/server/repository/credential"; import logger from "@calcom/lib/logger"; -import { CredentialRepository } from "../../../../lib/server/repository/credential"; import { routingFormIncompleteBookingDataSchema } from "../../zod"; import SalesforceCRMService from "../CrmService"; diff --git a/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts b/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts index 9bbecc9d04..01cc317aa3 100644 --- a/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts +++ b/packages/app-store/salesforce/lib/routingFormBookingFormHandler.ts @@ -1,4 +1,5 @@ -import { CredentialRepository } from "../../../lib/server/repository/credential"; +import { CredentialRepository } from "@calcom/lib/server/repository/credential"; + import type { AttributeRoutingConfig } from "../../routing-forms/types/types"; import SalesforceCRMService from "./CrmService"; import { SalesforceRecordEnum, RoutingReasons } from "./enums"; diff --git a/packages/app-store/server.ts b/packages/app-store/server.ts index a9467a93ac..a6729e9bad 100644 --- a/packages/app-store/server.ts +++ b/packages/app-store/server.ts @@ -1,10 +1,8 @@ import type { TFunction } from "i18next"; +import { enrichUserWithDelegationConferencingCredentialsWithoutOrgId } from "@calcom/app-store/delegationCredential"; import { defaultVideoAppCategories } from "@calcom/app-store/utils"; -import { - buildNonDelegationCredentials, - enrichUserWithDelegationConferencingCredentialsWithoutOrgId, -} from "@calcom/lib/delegationCredential/server"; +import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { AppCategories } from "@calcom/prisma/enums"; diff --git a/packages/features/Segment.tsx b/packages/features/Segment.tsx index 5aca7b7c1c..4e822000c3 100644 --- a/packages/features/Segment.tsx +++ b/packages/features/Segment.tsx @@ -12,7 +12,7 @@ import { import { getQueryBuilderConfigForAttributes } from "@calcom/app-store/routing-forms/lib/getQueryBuilderConfig"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { isEqual } from "@calcom/lib/isEqual"; -import { buildStateFromQueryValue } from "@calcom/lib/raqb/raqbUtils"; +import { buildStateFromQueryValue } from "@calcom/app-store/_utils/raqb/raqbUtils"; import type { AttributesQueryValue } from "@calcom/lib/raqb/types"; import { trpc, type RouterOutputs } from "@calcom/trpc"; import cn from "@calcom/ui/classNames"; diff --git a/packages/features/apps/components/AppList.tsx b/packages/features/apps/components/AppList.tsx index b22114e66c..10831c1d0d 100644 --- a/packages/features/apps/components/AppList.tsx +++ b/packages/features/apps/components/AppList.tsx @@ -12,7 +12,7 @@ import type { EventTypes, } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal"; import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { AppCategories } from "@calcom/prisma/enums"; import { type RouterOutputs } from "@calcom/trpc"; diff --git a/packages/features/apps/components/DisconnectIntegration.tsx b/packages/features/apps/components/DisconnectIntegration.tsx index 090f42a817..ff1b64971a 100644 --- a/packages/features/apps/components/DisconnectIntegration.tsx +++ b/packages/features/apps/components/DisconnectIntegration.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import type { ButtonProps } from "@calcom/ui/components/button"; diff --git a/packages/lib/server/findUsersForAvailabilityCheck.ts b/packages/features/availability/lib/findUsersForAvailabilityCheck.ts similarity index 85% rename from packages/lib/server/findUsersForAvailabilityCheck.ts rename to packages/features/availability/lib/findUsersForAvailabilityCheck.ts index b0ad6fe511..f56c719c16 100644 --- a/packages/lib/server/findUsersForAvailabilityCheck.ts +++ b/packages/features/availability/lib/findUsersForAvailabilityCheck.ts @@ -1,11 +1,10 @@ -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; +import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; +import { withSelectedCalendars } from "@calcom/lib/server/withSelectedCalendars"; import { availabilityUserSelect } from "@calcom/prisma"; import { prisma } from "@calcom/prisma"; import type { Prisma } from "@calcom/prisma/client"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; -import { withSelectedCalendars } from "./withSelectedCalendars"; - export async function findUsersForAvailabilityCheck({ where }: { where: Prisma.UserWhereInput }) { const user = await prisma.user.findFirst({ where, diff --git a/packages/lib/getUserAvailability.ts b/packages/features/availability/lib/getUserAvailability.ts similarity index 99% rename from packages/lib/getUserAvailability.ts rename to packages/features/availability/lib/getUserAvailability.ts index 47811c9eb6..d897a2e7be 100644 --- a/packages/lib/getUserAvailability.ts +++ b/packages/features/availability/lib/getUserAvailability.ts @@ -18,9 +18,10 @@ import { getBusyTimesFromLimits, getBusyTimesFromTeamLimits, } from "@calcom/lib/intervalLimits/server/getBusyTimesFromLimits"; +import { getPeriodStartDatesBetween as getPeriodStartDatesBetweenUtil } from "@calcom/lib/intervalLimits/utils/getPeriodStartDatesBetween"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; -import { findUsersForAvailabilityCheck } from "@calcom/lib/server/findUsersForAvailabilityCheck"; +import { withReporting } from "@calcom/lib/sentryWrapper"; import type { BookingRepository } from "@calcom/lib/server/repository/booking"; import { EventTypeRepository } from "@calcom/lib/server/repository/eventTypeRepository"; import type { PrismaOOORepository } from "@calcom/lib/server/repository/ooo"; @@ -37,8 +38,7 @@ import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; import type { EventBusyDetails, IntervalLimitUnit } from "@calcom/types/Calendar"; import type { TimeRange } from "@calcom/types/schedule"; -import { getPeriodStartDatesBetween as getPeriodStartDatesBetweenUtil } from "./intervalLimits/utils/getPeriodStartDatesBetween"; -import { withReporting } from "./sentryWrapper"; +import { findUsersForAvailabilityCheck } from "./findUsersForAvailabilityCheck"; const log = logger.getSubLogger({ prefix: ["getUserAvailability"] }); const availabilitySchema = z diff --git a/packages/features/bookings/Booker/components/OutOfOfficeInSlots.tsx b/packages/features/bookings/Booker/components/OutOfOfficeInSlots.tsx index 6f51ea7b0f..a0fa7d76a1 100644 --- a/packages/features/bookings/Booker/components/OutOfOfficeInSlots.tsx +++ b/packages/features/bookings/Booker/components/OutOfOfficeInSlots.tsx @@ -1,7 +1,7 @@ import { useRouter } from "next/navigation"; import ServerTrans from "@calcom/lib/components/ServerTrans"; -import type { IOutOfOfficeData } from "@calcom/lib/getUserAvailability"; +import type { IOutOfOfficeData } from "@calcom/features/availability/lib/getUserAvailability"; import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import classNames from "@calcom/ui/classNames"; diff --git a/packages/features/bookings/components/AvailableTimes.tsx b/packages/features/bookings/components/AvailableTimes.tsx index c9a1c97cc8..bb58f211c7 100644 --- a/packages/features/bookings/components/AvailableTimes.tsx +++ b/packages/features/bookings/components/AvailableTimes.tsx @@ -11,7 +11,7 @@ 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 type { IOutOfOfficeData } from "@calcom/lib/getUserAvailability"; +import type { IOutOfOfficeData } from "@calcom/features/availability/lib/getUserAvailability"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { localStorage } from "@calcom/lib/webstorage"; import classNames from "@calcom/ui/classNames"; diff --git a/packages/features/bookings/lib/EventManager.ts b/packages/features/bookings/lib/EventManager.ts index c4e6e9662b..272e7aca53 100644 --- a/packages/features/bookings/lib/EventManager.ts +++ b/packages/features/bookings/lib/EventManager.ts @@ -8,10 +8,14 @@ import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApi import { appKeysSchema as calVideoKeysSchema } from "@calcom/app-store/dailyvideo/zod"; import { getLocationFromApp, MeetLocationType, MSTeamsLocationType } from "@calcom/app-store/locations"; import getApps from "@calcom/app-store/utils"; +import { createMeeting, updateMeeting, deleteMeeting } from "@calcom/app-store/videoClient"; +import { createEvent, updateEvent, deleteEvent } from "@calcom/features/calendars/lib/CalendarManager"; +import CrmManager from "@calcom/features/crmManager/crmManager"; import { FeaturesRepository } from "@calcom/features/flags/features.repository"; import { getUid } from "@calcom/lib/CalEventParser"; import CRMScheduler from "@calcom/lib/crmManager/tasker/crmScheduler"; import { symmetricDecrypt } from "@calcom/lib/crypto"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; import { getPiiFreeDestinationCalendar, @@ -34,11 +38,6 @@ import type { PartialReference, } from "@calcom/types/EventManager"; -import { createEvent, updateEvent, deleteEvent } from "@calcom/features/calendars/lib/CalendarManager"; -import CrmManager from "@calcom/lib/crmManager/crmManager"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; -import { createMeeting, updateMeeting, deleteMeeting } from "@calcom/app-store/videoClient"; - const log = logger.getSubLogger({ prefix: ["EventManager"] }); const CALENDSO_ENCRYPTION_KEY = process.env.CALENDSO_ENCRYPTION_KEY || ""; const CALDAV_CALENDAR_TYPE = "caldav_calendar"; diff --git a/packages/features/bookings/lib/conflictChecker/checkForConflicts.test.ts b/packages/features/bookings/lib/conflictChecker/checkForConflicts.test.ts index f572c4658f..d0c1fe13fc 100644 --- a/packages/features/bookings/lib/conflictChecker/checkForConflicts.test.ts +++ b/packages/features/bookings/lib/conflictChecker/checkForConflicts.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import dayjs from "@calcom/dayjs"; -import type { CurrentSeats } from "@calcom/lib/getUserAvailability"; +import type { CurrentSeats } from "@calcom/features/availability/lib/getUserAvailability"; import type { EventBusyDate } from "@calcom/types/Calendar"; import { checkForConflicts } from "./checkForConflicts"; diff --git a/packages/features/bookings/lib/conflictChecker/checkForConflicts.ts b/packages/features/bookings/lib/conflictChecker/checkForConflicts.ts index 39125ec317..17aecb97ee 100644 --- a/packages/features/bookings/lib/conflictChecker/checkForConflicts.ts +++ b/packages/features/bookings/lib/conflictChecker/checkForConflicts.ts @@ -1,7 +1,7 @@ import type { Dayjs } from "dayjs"; import dayjs from "@calcom/dayjs"; -import type { CurrentSeats } from "@calcom/lib/getUserAvailability"; +import type { CurrentSeats } from "@calcom/features/availability/lib/getUserAvailability"; import type { BufferedBusyTime } from "@calcom/types/BufferedBusyTime"; type BufferedBusyTimes = BufferedBusyTime[]; diff --git a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts index eeca15bcac..385d485281 100644 --- a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts +++ b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials.ts @@ -1,7 +1,7 @@ import type { z } from "zod"; import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; +import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import { UserRepository } from "@calcom/lib/server/repository/user"; import prisma from "@calcom/prisma"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; diff --git a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials.ts b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials.ts index 352e784fd8..e132c26c67 100644 --- a/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials.ts +++ b/packages/features/bookings/lib/getAllCredentialsForUsersOnEvent/refreshCredentials.ts @@ -1,7 +1,7 @@ import async from "async"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; -import { buildAllCredentials } from "@calcom/lib/delegationCredential/server"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; +import { buildAllCredentials } from "@calcom/app-store/delegationCredential"; import { withReporting } from "@calcom/lib/sentryWrapper"; import type { CredentialForCalendarService } from "@calcom/types/Credential"; diff --git a/packages/lib/server/getLuckyUser.test.ts b/packages/features/bookings/lib/getLuckyUser.test.ts similarity index 99% rename from packages/lib/server/getLuckyUser.test.ts rename to packages/features/bookings/lib/getLuckyUser.test.ts index 75958d51b6..08e553a83b 100644 --- a/packages/lib/server/getLuckyUser.test.ts +++ b/packages/features/bookings/lib/getLuckyUser.test.ts @@ -1,5 +1,5 @@ -import CalendarManagerMock from "../../../tests/libs/__mocks__/CalendarManager"; -import prismaMock from "../../../tests/libs/__mocks__/prismaMock"; +import CalendarManagerMock from "../../../../tests/libs/__mocks__/CalendarManager"; +import prismaMock from "../../../../tests/libs/__mocks__/prismaMock"; import { v4 as uuid } from "uuid"; import { expect, it, describe, vi, beforeAll } from "vitest"; diff --git a/packages/lib/server/getLuckyUser.ts b/packages/features/bookings/lib/getLuckyUser.ts similarity index 99% rename from packages/lib/server/getLuckyUser.ts rename to packages/features/bookings/lib/getLuckyUser.ts index e1ec8cda11..6571645b98 100644 --- a/packages/lib/server/getLuckyUser.ts +++ b/packages/features/bookings/lib/getLuckyUser.ts @@ -1,9 +1,10 @@ +import { acrossQueryValueCompatiblity } from "@calcom/app-store/_utils/raqb/raqbUtils"; import type { FormResponse, Fields } from "@calcom/app-store/routing-forms/types/types"; import { zodRoutes } from "@calcom/app-store/routing-forms/zod"; import dayjs from "@calcom/dayjs"; import { getBusyCalendarTimes } from "@calcom/features/calendars/lib/CalendarManager"; +import { mergeOverlappingRanges } from "@calcom/lib/date-ranges"; import logger from "@calcom/lib/logger"; -import { acrossQueryValueCompatiblity } from "@calcom/lib/raqb/raqbUtils"; import { raqbQueryValueSchema } from "@calcom/lib/raqb/zod"; import { safeStringify } from "@calcom/lib/safeStringify"; import type { PrismaAttributeRepository } from "@calcom/lib/server/repository/PrismaAttributeRepository"; @@ -18,8 +19,6 @@ import { RRTimestampBasis, RRResetInterval } from "@calcom/prisma/enums"; import type { EventBusyDate } from "@calcom/types/Calendar"; import type { CredentialForCalendarService } from "@calcom/types/Credential"; -import { mergeOverlappingRanges } from "../date-ranges"; - const log = logger.getSubLogger({ prefix: ["getLuckyUser"] }); const { getAttributesQueryValue } = acrossQueryValueCompatiblity; diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index d473c146dd..80f28a1fac 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1,9 +1,10 @@ - import short, { uuid } from "short-uuid"; import { v5 as uuidv5 } from "uuid"; import processExternalId from "@calcom/app-store/_utils/calendars/processExternalId"; import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData"; +import { getFirstDelegationConferencingCredentialAppLocation } from "@calcom/app-store/delegationCredential"; +import { enrichHostsWithDelegationCredentials } from "@calcom/app-store/delegationCredential"; import { metadata as GoogleMeetMetadata } from "@calcom/app-store/googlevideo/_metadata"; import { getLocationValueForDB, @@ -25,6 +26,9 @@ import { handlePayment } from "@calcom/features/bookings/lib/handlePayment"; import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger"; import { isEventTypeLoggingEnabled } from "@calcom/features/bookings/lib/isEventTypeLoggingEnabled"; import type { CacheService } from "@calcom/features/calendar-cache/lib/getShouldServeCache"; +import { getCheckBookingAndDurationLimitsService } from "@calcom/features/di/containers/BookingLimits"; +import { getCacheService } from "@calcom/features/di/containers/Cache"; +import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import AssignmentReasonRecorder from "@calcom/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder"; import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents"; import { getEventName, updateHostInEventName } from "@calcom/features/eventtypes/lib/eventNaming"; @@ -43,13 +47,6 @@ import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser"; import { groupHostsByGroupId } from "@calcom/lib/bookings/hostGroupUtils"; import { shouldIgnoreContactOwner } from "@calcom/lib/bookings/routing/utils"; import { DEFAULT_GROUP_ID } from "@calcom/lib/constants"; -import { - enrichHostsWithDelegationCredentials, - getFirstDelegationConferencingCredentialAppLocation, -} from "@calcom/lib/delegationCredential/server"; -import { getCheckBookingAndDurationLimitsService } from "@calcom/features/di/containers/BookingLimits"; -import { getCacheService } from "@calcom/features/di/containers/Cache"; -import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import { ErrorCode } from "@calcom/lib/errorCodes"; import { getErrorFromUnknown } from "@calcom/lib/errors"; import { extractBaseEmail } from "@calcom/lib/extract-base-email"; @@ -1480,7 +1477,8 @@ async function handler( const changedOrganizer = !!originalRescheduledBooking && - (eventType.schedulingType === SchedulingType.ROUND_ROBIN || eventType.schedulingType === SchedulingType.COLLECTIVE) && + (eventType.schedulingType === SchedulingType.ROUND_ROBIN || + eventType.schedulingType === SchedulingType.COLLECTIVE) && originalRescheduledBooking.userId !== evt.organizer.id; const skipDeleteEventsAndMeetings = changedOrganizer; diff --git a/packages/features/bookings/lib/handleNewBooking/getLocationValuesForDb.ts b/packages/features/bookings/lib/handleNewBooking/getLocationValuesForDb.ts index acbd66133c..743d76e30c 100644 --- a/packages/features/bookings/lib/handleNewBooking/getLocationValuesForDb.ts +++ b/packages/features/bookings/lib/handleNewBooking/getLocationValuesForDb.ts @@ -1,4 +1,4 @@ -import { getFirstDelegationConferencingCredentialAppLocation } from "@calcom/lib/delegationCredential/server"; +import { getFirstDelegationConferencingCredentialAppLocation } from "@calcom/app-store/delegationCredential"; import { withReporting } from "@calcom/lib/sentryWrapper"; import type { Prisma } from "@calcom/prisma/client"; import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils"; diff --git a/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts b/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts index 4167f74623..d7f6afce7a 100644 --- a/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts +++ b/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts @@ -1,14 +1,14 @@ import type { Logger } from "tslog"; -import { checkIfUsersAreBlocked } from "@calcom/features/watchlist/operations/check-if-users-are-blocked.controller"; -import { enrichUsersWithDelegationCredentials } from "@calcom/lib/delegationCredential/server"; +import { enrichUsersWithDelegationCredentials } from "@calcom/app-store/delegationCredential"; +import type { RoutingFormResponse } from "@calcom/features/bookings/lib/getLuckyUser"; import { getQualifiedHostsService } from "@calcom/features/di/containers/QualifiedHosts"; +import { checkIfUsersAreBlocked } from "@calcom/features/watchlist/operations/check-if-users-are-blocked.controller"; import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId"; import { HttpError } from "@calcom/lib/http-error"; import { getPiiFreeUser } from "@calcom/lib/piiFreeData"; import { safeStringify } from "@calcom/lib/safeStringify"; import { withReporting } from "@calcom/lib/sentryWrapper"; -import type { RoutingFormResponse } from "@calcom/lib/server/getLuckyUser"; import { withSelectedCalendars } from "@calcom/lib/server/repository/user"; import { userSelect } from "@calcom/prisma"; import prisma from "@calcom/prisma"; diff --git a/packages/features/bookings/lib/handleNewBooking/loadUsers.ts b/packages/features/bookings/lib/handleNewBooking/loadUsers.ts index 5ec28263e9..048ef5b2d4 100644 --- a/packages/features/bookings/lib/handleNewBooking/loadUsers.ts +++ b/packages/features/bookings/lib/handleNewBooking/loadUsers.ts @@ -3,7 +3,7 @@ import { getRoutedUsersWithContactOwnerAndFixedUsers, findMatchingHostsWithEventSegment, getNormalizedHosts, -} from "@calcom/lib/bookings/getRoutedUsers"; +} from "@calcom/features/users/lib/getRoutedUsers"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; diff --git a/packages/features/bookings/lib/handleNewBooking/test/getLocationValueForDb.test.ts b/packages/features/bookings/lib/handleNewBooking/test/getLocationValueForDb.test.ts index acef560d54..71d01ead93 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/getLocationValueForDb.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/getLocationValueForDb.test.ts @@ -9,7 +9,7 @@ vi.mock("@calcom/prisma/zod-utils", () => ({ userMetadata: { parse: (metadata: any) => metadata }, })); -vi.mock("@calcom/lib/delegationCredential/server", () => ({ +vi.mock("@calcom/app-store/delegationCredential", () => ({ getFirstDelegationConferencingCredentialAppLocation: ({ credentials, }: { diff --git a/packages/features/bookings/lib/handleNewBooking/types.ts b/packages/features/bookings/lib/handleNewBooking/types.ts index 2cc05361c1..1f0c873529 100644 --- a/packages/features/bookings/lib/handleNewBooking/types.ts +++ b/packages/features/bookings/lib/handleNewBooking/types.ts @@ -2,7 +2,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 { GetUserAvailabilityResult } from "@calcom/lib/getUserAvailability"; +import type { GetUserAvailabilityResult } from "@calcom/features/availability/lib/getUserAvailability"; import type { userSelect } from "@calcom/prisma"; import type { App } from "@calcom/prisma/client"; import type { Prisma } from "@calcom/prisma/client"; diff --git a/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts b/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts index 1a59292c84..9517f7f88b 100644 --- a/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts +++ b/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts @@ -3,8 +3,8 @@ import { sendCancelledSeatEmailsAndSMS } from "@calcom/emails"; import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload"; import type { EventPayloadType, EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload"; import { getRichDescription } from "@calcom/lib/CalEventParser"; -import { getAllDelegationCredentialsForUserIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; -import { getDelegationCredentialOrFindRegularCredential } from "@calcom/lib/delegationCredential/server"; +import { getAllDelegationCredentialsForUserIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; +import { getDelegationCredentialOrFindRegularCredential } from "@calcom/app-store/delegationCredential"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; diff --git a/packages/features/bookings/lib/handleSeats/lib/lastAttendeeDeleteBooking.ts b/packages/features/bookings/lib/handleSeats/lib/lastAttendeeDeleteBooking.ts index 846aa640e9..c162be8d16 100644 --- a/packages/features/bookings/lib/handleSeats/lib/lastAttendeeDeleteBooking.ts +++ b/packages/features/bookings/lib/handleSeats/lib/lastAttendeeDeleteBooking.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line no-restricted-imports import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; -import { getAllDelegationCredentialsForUserIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; -import { getDelegationCredentialOrFindRegularCredential } from "@calcom/lib/delegationCredential/server"; +import { getAllDelegationCredentialsForUserIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; +import { getDelegationCredentialOrFindRegularCredential } from "@calcom/app-store/delegationCredential"; import { deleteMeeting } from "@calcom/app-store/videoClient"; import prisma from "@calcom/prisma"; import type { Attendee } from "@calcom/prisma/client"; diff --git a/packages/lib/bookings/filterHostsByLeadThreshold.test.ts b/packages/features/bookings/lib/host-filtering/filterHostsByLeadThreshold.test.ts similarity index 100% rename from packages/lib/bookings/filterHostsByLeadThreshold.test.ts rename to packages/features/bookings/lib/host-filtering/filterHostsByLeadThreshold.test.ts diff --git a/packages/lib/bookings/filterHostsByLeadThreshold.ts b/packages/features/bookings/lib/host-filtering/filterHostsByLeadThreshold.ts similarity index 98% rename from packages/lib/bookings/filterHostsByLeadThreshold.ts rename to packages/features/bookings/lib/host-filtering/filterHostsByLeadThreshold.ts index 8f7b6ac408..be3be96f6d 100644 --- a/packages/lib/bookings/filterHostsByLeadThreshold.ts +++ b/packages/features/bookings/lib/host-filtering/filterHostsByLeadThreshold.ts @@ -1,11 +1,10 @@ import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import logger from "@calcom/lib/logger"; +import type { LuckyUserService, RoutingFormResponse } from "@calcom/features/bookings/lib/getLuckyUser"; import type { RRResetInterval, SelectedCalendar } from "@calcom/prisma/client"; import { RRTimestampBasis } from "@calcom/prisma/enums"; import type { CredentialForCalendarService } from "@calcom/types/Credential"; -import type { LuckyUserService, RoutingFormResponse } from "../server/getLuckyUser"; - export const errorCodes = { MAX_LEAD_THRESHOLD_FALSY: "Max lead threshold should be null or > 1, not 0.", } as const; diff --git a/packages/lib/bookings/filterHostsBySameRoundRobinHost.test.ts b/packages/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost.test.ts similarity index 100% rename from packages/lib/bookings/filterHostsBySameRoundRobinHost.test.ts rename to packages/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost.test.ts diff --git a/packages/lib/bookings/filterHostsBySameRoundRobinHost.ts b/packages/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost.ts similarity index 95% rename from packages/lib/bookings/filterHostsBySameRoundRobinHost.ts rename to packages/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost.ts index 1c54960272..b34f7c46a1 100644 --- a/packages/lib/bookings/filterHostsBySameRoundRobinHost.ts +++ b/packages/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost.ts @@ -1,7 +1,6 @@ +import { isRerouting } from "@calcom/lib/bookings/routing/utils"; import type { BookingRepository } from "@calcom/lib/server/repository/booking"; -import { isRerouting } from "./routing/utils"; - export interface IFilterHostsService { bookingRepo: BookingRepository; } diff --git a/packages/lib/bookings/findQualifiedHostsWithDelegationCredentials.test.ts b/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts similarity index 99% rename from packages/lib/bookings/findQualifiedHostsWithDelegationCredentials.test.ts rename to packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts index c4bd709802..2d067dc12c 100644 --- a/packages/lib/bookings/findQualifiedHostsWithDelegationCredentials.test.ts +++ b/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.test.ts @@ -1,13 +1,13 @@ -import prismaMock from "../../../tests/libs/__mocks__/prismaMock"; +import prismaMock from "../../../../../tests/libs/__mocks__/prismaMock"; import { vi, it, describe, expect, afterEach } from "vitest"; import type { Mock } from "vitest"; import { getQualifiedHostsService } from "@calcom/features/di/containers/QualifiedHosts"; +import * as getRoutedUsers from "@calcom/features/users/lib/getRoutedUsers"; import { RRResetInterval, SchedulingType } from "@calcom/prisma/enums"; import { filterHostsByLeadThreshold } from "./filterHostsByLeadThreshold"; -import * as getRoutedUsers from "./getRoutedUsers"; // Mock the filterHostsByLeadThreshold function vi.mock("./filterHostsByLeadThreshold", () => { diff --git a/packages/lib/bookings/findQualifiedHostsWithDelegationCredentials.ts b/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.ts similarity index 96% rename from packages/lib/bookings/findQualifiedHostsWithDelegationCredentials.ts rename to packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.ts index 02273ea97d..611a3c48af 100644 --- a/packages/lib/bookings/findQualifiedHostsWithDelegationCredentials.ts +++ b/packages/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials.ts @@ -1,17 +1,17 @@ -import type { FilterHostsService } from "@calcom/lib/bookings/filterHostsBySameRoundRobinHost"; import { findMatchingHostsWithEventSegment, getNormalizedHostsWithDelegationCredentials, -} from "@calcom/lib/bookings/getRoutedUsers"; -import type { EventType } from "@calcom/lib/bookings/getRoutedUsers"; +} from "@calcom/features/users/lib/getRoutedUsers"; +import type { EventType } from "@calcom/features/users/lib/getRoutedUsers"; import { withReporting } from "@calcom/lib/sentryWrapper"; +import type { RoutingFormResponse } from "@calcom/features/bookings/lib/getLuckyUser"; import type { BookingRepository } from "@calcom/lib/server/repository/booking"; import type { SelectedCalendar } from "@calcom/prisma/client"; import type { SchedulingType } from "@calcom/prisma/enums"; import type { CredentialForCalendarService, CredentialPayload } from "@calcom/types/Credential"; -import type { RoutingFormResponse } from "../server/getLuckyUser"; import { filterHostsByLeadThreshold } from "./filterHostsByLeadThreshold"; +import type { FilterHostsService } from "./filterHostsBySameRoundRobinHost"; export interface IQualifiedHostsService { bookingRepo: BookingRepository; diff --git a/packages/features/bookings/lib/payment/getBooking.ts b/packages/features/bookings/lib/payment/getBooking.ts index fd0f0dd014..2d33d57d3b 100644 --- a/packages/features/bookings/lib/payment/getBooking.ts +++ b/packages/features/bookings/lib/payment/getBooking.ts @@ -1,6 +1,6 @@ import { workflowSelect } from "@calcom/ee/workflows/lib/getAllWorkflows"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; -import { enrichUserWithDelegationCredentials } from "@calcom/lib/delegationCredential/server"; +import { enrichUserWithDelegationCredentials } from "@calcom/app-store/delegationCredential"; import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server"; import { HttpError as HttpCode } from "@calcom/lib/http-error"; import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj"; diff --git a/packages/features/calendar-cache/calendar-cache.repository.ts b/packages/features/calendar-cache/calendar-cache.repository.ts index ef01a60c10..6cd1100e5b 100644 --- a/packages/features/calendar-cache/calendar-cache.repository.ts +++ b/packages/features/calendar-cache/calendar-cache.repository.ts @@ -1,5 +1,5 @@ import { uniqueBy } from "@calcom/lib/array"; -import { isInMemoryDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; +import { isInMemoryDelegationCredential } from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; import prisma from "@calcom/prisma"; diff --git a/packages/features/calendar-cache/calendar-cache.ts b/packages/features/calendar-cache/calendar-cache.ts index cddf821034..2ca45693a7 100644 --- a/packages/features/calendar-cache/calendar-cache.ts +++ b/packages/features/calendar-cache/calendar-cache.ts @@ -1,6 +1,6 @@ import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; import { FeaturesRepository } from "@calcom/features/flags/features.repository"; -import { getCredentialForCalendarCache } from "@calcom/lib/delegationCredential/server"; +import { getCredentialForCalendarCache } from "@calcom/app-store/delegationCredential"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; import prisma from "@calcom/prisma"; diff --git a/packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts b/packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts index 0dfe81febc..236a718392 100644 --- a/packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts +++ b/packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts @@ -1,3 +1,4 @@ +import { getCredentialForSelectedCalendar } from "@calcom/app-store/delegationCredential"; import type { AdapterFactory, CalendarSubscriptionProvider, @@ -9,7 +10,6 @@ import type { import type { CalendarCacheEventService } from "@calcom/features/calendar-subscription/lib/cache/CalendarCacheEventService"; import type { CalendarSyncService } from "@calcom/features/calendar-subscription/lib/sync/CalendarSyncService"; import type { FeaturesRepository } from "@calcom/features/flags/features.repository"; -import { getCredentialForSelectedCalendar } from "@calcom/lib/delegationCredential/server"; import logger from "@calcom/lib/logger"; import type { ISelectedCalendarRepository } from "@calcom/lib/server/repository/SelectedCalendarRepository.interface"; import { SelectedCalendar } from "@calcom/prisma/client"; diff --git a/packages/features/calendar-subscription/lib/__mocks__/delegationCredential.ts b/packages/features/calendar-subscription/lib/__mocks__/delegationCredential.ts index 40ca631e65..d863e78ca9 100644 --- a/packages/features/calendar-subscription/lib/__mocks__/delegationCredential.ts +++ b/packages/features/calendar-subscription/lib/__mocks__/delegationCredential.ts @@ -7,6 +7,6 @@ export const getCredentialForSelectedCalendar = vi.fn().mockResolvedValue({ delegatedTo: null, }); -vi.doMock("@calcom/lib/delegationCredential/server", () => ({ +vi.doMock("@calcom/app-store/delegationCredential", () => ({ getCredentialForSelectedCalendar, })); diff --git a/packages/features/calendars/DatePicker.tsx b/packages/features/calendars/DatePicker.tsx index 4936c2c2f5..d5c2b8bccf 100644 --- a/packages/features/calendars/DatePicker.tsx +++ b/packages/features/calendars/DatePicker.tsx @@ -7,7 +7,7 @@ import { useEmbedStyles } from "@calcom/embed-core/embed-iframe"; import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider"; import { getAvailableDatesInMonth } from "@calcom/features/calendars/lib/getAvailableDatesInMonth"; import { daysInMonth, yyyymmdd } from "@calcom/lib/dayjs"; -import type { IFromUser, IToUser } from "@calcom/lib/getUserAvailability"; +import type { IFromUser, IToUser } from "@calcom/features/availability/lib/getUserAvailability"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { weekdayNames } from "@calcom/lib/weekday"; import type { PeriodData } from "@calcom/types/Event"; diff --git a/packages/features/calendars/lib/CalendarManager.ts b/packages/features/calendars/lib/CalendarManager.ts index ce07a06454..d677806a00 100644 --- a/packages/features/calendars/lib/CalendarManager.ts +++ b/packages/features/calendars/lib/CalendarManager.ts @@ -5,14 +5,15 @@ import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; import { MeetLocationType } from "@calcom/app-store/locations"; import getApps from "@calcom/app-store/utils"; import dayjs from "@calcom/dayjs"; +import getCalendarsEvents, { + getCalendarsEventsWithTimezones, +} from "@calcom/features/calendars/lib/getCalendarsEvents"; import { getUid } from "@calcom/lib/CalEventParser"; import { getRichDescription } from "@calcom/lib/CalEventParser"; import { CalendarAppDelegationCredentialError } from "@calcom/lib/CalendarAppError"; import { ORGANIZER_EMAIL_EXEMPT_DOMAINS } from "@calcom/lib/constants"; -import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential/clientAndServer"; +import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; import { formatCalEvent } from "@calcom/lib/formatCalendarEvent"; -import getCalendarsEvents from "@calcom/lib/getCalendarsEvents"; -import { getCalendarsEventsWithTimezones } from "@calcom/lib/getCalendarsEvents"; import logger from "@calcom/lib/logger"; import { getPiiFreeCalendarEvent, getPiiFreeCredential } from "@calcom/lib/piiFreeData"; import { safeStringify } from "@calcom/lib/safeStringify"; diff --git a/packages/lib/getCalendarsEvents.test.ts b/packages/features/calendars/lib/getCalendarsEvents.test.ts similarity index 99% rename from packages/lib/getCalendarsEvents.test.ts rename to packages/features/calendars/lib/getCalendarsEvents.test.ts index fced2a1625..2c938bd833 100644 --- a/packages/lib/getCalendarsEvents.test.ts +++ b/packages/features/calendars/lib/getCalendarsEvents.test.ts @@ -1,21 +1,21 @@ -import "../../tests/libs/__mocks__/prisma"; +import "../../../../tests/libs/__mocks__/prisma"; import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; import GoogleCalendarService from "@calcom/app-store/googlecalendar/lib/CalendarService"; import OfficeCalendarService from "@calcom/app-store/office365calendar/lib/CalendarService"; +import { symmetricDecrypt } from "@calcom/lib/crypto"; import logger from "@calcom/lib/logger"; import type { SelectedCalendar } from "@calcom/prisma/client"; import type { EventBusyDate } from "@calcom/types/Calendar"; import type { CredentialForCalendarService, CredentialPayload } from "@calcom/types/Credential"; -import { symmetricDecrypt } from "./crypto"; import getCalendarsEvents, { getCalendarsEventsWithTimezones, filterSelectedCalendarsForCredential, } from "./getCalendarsEvents"; -vi.mock("./crypto", () => ({ +vi.mock("@calcom/lib/crypto", () => ({ symmetricDecrypt: vi.fn(), })); diff --git a/packages/lib/getCalendarsEvents.ts b/packages/features/calendars/lib/getCalendarsEvents.ts similarity index 99% rename from packages/lib/getCalendarsEvents.ts rename to packages/features/calendars/lib/getCalendarsEvents.ts index d382dc6a75..0acd396925 100644 --- a/packages/lib/getCalendarsEvents.ts +++ b/packages/features/calendars/lib/getCalendarsEvents.ts @@ -1,5 +1,6 @@ import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; +import { symmetricDecrypt } from "@calcom/lib/crypto"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; import { getPiiFreeSelectedCalendar, getPiiFreeCredential } from "@calcom/lib/piiFreeData"; import { safeStringify } from "@calcom/lib/safeStringify"; @@ -7,8 +8,6 @@ import { performance } from "@calcom/lib/server/perfObserver"; import type { EventBusyDate, SelectedCalendar } from "@calcom/types/Calendar"; import type { CredentialForCalendarService } from "@calcom/types/Credential"; -import { symmetricDecrypt } from "./crypto"; - const log = logger.getSubLogger({ prefix: ["getCalendarsEvents"] }); const CALENDSO_ENCRYPTION_KEY = process.env.CALENDSO_ENCRYPTION_KEY || ""; diff --git a/packages/lib/getConnectedDestinationCalendars.ts b/packages/features/calendars/lib/getConnectedDestinationCalendars.ts similarity index 96% rename from packages/lib/getConnectedDestinationCalendars.ts rename to packages/features/calendars/lib/getConnectedDestinationCalendars.ts index 1ab9366851..fdcbafadbe 100644 --- a/packages/lib/getConnectedDestinationCalendars.ts +++ b/packages/features/calendars/lib/getConnectedDestinationCalendars.ts @@ -1,17 +1,19 @@ -import { getCalendarCredentials, getConnectedCalendars } from "@calcom/features/calendars/lib/CalendarManager"; -import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer"; -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; +import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; +import { + getCalendarCredentials, + getConnectedCalendars, +} from "@calcom/features/calendars/lib/CalendarManager"; +import { isDelegationCredential } from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; +import { DestinationCalendarRepository } from "@calcom/lib/server/repository/destinationCalendar"; +import { EventTypeRepository } from "@calcom/lib/server/repository/eventTypeRepository"; +import { SelectedCalendarRepository } from "@calcom/lib/server/repository/selectedCalendar"; import type { PrismaClient } from "@calcom/prisma"; import prisma from "@calcom/prisma"; import type { DestinationCalendar, SelectedCalendar, User } from "@calcom/prisma/client"; import { AppCategories } from "@calcom/prisma/enums"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; -import { DestinationCalendarRepository } from "./server/repository/destinationCalendar"; -import { EventTypeRepository } from "./server/repository/eventTypeRepository"; -import { SelectedCalendarRepository } from "./server/repository/selectedCalendar"; - const log = logger.getSubLogger({ prefix: ["getConnectedDestinationCalendarsAndEnsureDefaultsInDb"] }); type ReturnTypeGetConnectedCalendars = Awaited>; diff --git a/packages/features/calendars/weeklyview/types/state.ts b/packages/features/calendars/weeklyview/types/state.ts index d87c66a00a..f16b4597bf 100644 --- a/packages/features/calendars/weeklyview/types/state.ts +++ b/packages/features/calendars/weeklyview/types/state.ts @@ -1,4 +1,4 @@ -import type { IFromUser, IToUser } from "@calcom/lib/getUserAvailability"; +import type { IFromUser, IToUser } from "@calcom/features/availability/lib/getUserAvailability"; import type { TimeRange } from "@calcom/types/schedule"; import type { CalendarEvent } from "./events"; diff --git a/packages/features/credentials/handleDeleteCredential.ts b/packages/features/credentials/handleDeleteCredential.ts index 3581a4fe10..dd58639ac8 100644 --- a/packages/features/credentials/handleDeleteCredential.ts +++ b/packages/features/credentials/handleDeleteCredential.ts @@ -12,7 +12,7 @@ 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 { buildNonDelegationCredential } from "@calcom/lib/delegationCredential"; import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj"; import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent"; import { getTranslation } from "@calcom/lib/server/i18n"; diff --git a/packages/lib/crmManager/crmManager.test.ts b/packages/features/crmManager/crmManager.test.ts similarity index 100% rename from packages/lib/crmManager/crmManager.test.ts rename to packages/features/crmManager/crmManager.test.ts diff --git a/packages/lib/crmManager/crmManager.ts b/packages/features/crmManager/crmManager.ts similarity index 100% rename from packages/lib/crmManager/crmManager.ts rename to packages/features/crmManager/crmManager.ts diff --git a/packages/features/di/containers/FilterHosts.ts b/packages/features/di/containers/FilterHosts.ts index 3672a0f5c4..b274855316 100644 --- a/packages/features/di/containers/FilterHosts.ts +++ b/packages/features/di/containers/FilterHosts.ts @@ -1,7 +1,7 @@ +import type { FilterHostsService } from "@calcom/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost"; import { DI_TOKENS } from "@calcom/features/di/tokens"; import { prismaModule } from "@calcom/prisma/prisma.module"; -import type { FilterHostsService } from "../../bookings/filterHostsBySameRoundRobinHost"; import { createContainer } from "../di"; import { bookingRepositoryModule } from "../modules/Booking"; import { filterHostsModule } from "../modules/FilterHosts"; diff --git a/packages/features/di/containers/GetUserAvailability.ts b/packages/features/di/containers/GetUserAvailability.ts index dc701a2f77..a56890ea1e 100644 --- a/packages/features/di/containers/GetUserAvailability.ts +++ b/packages/features/di/containers/GetUserAvailability.ts @@ -1,6 +1,6 @@ import { DI_TOKENS } from "@calcom/features/di/tokens"; import { redisModule } from "@calcom/features/redis/di/redisModule"; -import type { UserAvailabilityService } from "@calcom/lib/getUserAvailability"; +import type { UserAvailabilityService } from "@calcom/features/availability/lib/getUserAvailability"; import { prismaModule } from "@calcom/prisma/prisma.module"; import { createContainer } from "../di"; diff --git a/packages/features/di/containers/LuckyUser.ts b/packages/features/di/containers/LuckyUser.ts index 953ddeaae1..a7299db201 100644 --- a/packages/features/di/containers/LuckyUser.ts +++ b/packages/features/di/containers/LuckyUser.ts @@ -1,4 +1,4 @@ -import type { LuckyUserService } from "@calcom/lib/server/getLuckyUser"; +import type { LuckyUserService } from "@calcom/features/bookings/lib/getLuckyUser"; import { createContainer } from "../di"; import { moduleLoader as luckyUserServiceModuleLoader } from "../modules/LuckyUser"; diff --git a/packages/features/di/containers/QualifiedHosts.ts b/packages/features/di/containers/QualifiedHosts.ts index 7fb9a6f963..67e4e3e71a 100644 --- a/packages/features/di/containers/QualifiedHosts.ts +++ b/packages/features/di/containers/QualifiedHosts.ts @@ -1,5 +1,5 @@ +import type { QualifiedHostsService } from "@calcom/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials"; import { DI_TOKENS } from "@calcom/features/di/tokens"; -import type { QualifiedHostsService } from "@calcom/lib/bookings/findQualifiedHostsWithDelegationCredentials"; import { prismaModule } from "@calcom/prisma/prisma.module"; import { createContainer } from "../di"; diff --git a/packages/features/di/modules/FilterHosts.ts b/packages/features/di/modules/FilterHosts.ts index 5076e0bad5..54c8d94b56 100644 --- a/packages/features/di/modules/FilterHosts.ts +++ b/packages/features/di/modules/FilterHosts.ts @@ -1,5 +1,5 @@ -import type { IFilterHostsService } from "@calcom/lib/bookings/filterHostsBySameRoundRobinHost"; -import { FilterHostsService } from "@calcom/lib/bookings/filterHostsBySameRoundRobinHost"; +import type { IFilterHostsService } from "@calcom/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost"; +import { FilterHostsService } from "@calcom/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost"; import { createModule } from "../di"; import { DI_TOKENS } from "../tokens"; diff --git a/packages/features/di/modules/GetUserAvailability.ts b/packages/features/di/modules/GetUserAvailability.ts index b45a895b95..42a915f8d6 100644 --- a/packages/features/di/modules/GetUserAvailability.ts +++ b/packages/features/di/modules/GetUserAvailability.ts @@ -1,5 +1,5 @@ -import type { IUserAvailabilityService } from "@calcom/lib/getUserAvailability"; -import { UserAvailabilityService } from "@calcom/lib/getUserAvailability"; +import type { IUserAvailabilityService } from "@calcom/features/availability/lib/getUserAvailability"; +import { UserAvailabilityService } from "@calcom/features/availability/lib/getUserAvailability"; import { createModule } from "../di"; import { DI_TOKENS } from "../tokens"; diff --git a/packages/features/di/modules/LuckyUser.ts b/packages/features/di/modules/LuckyUser.ts index c34dc032c0..359b928af4 100644 --- a/packages/features/di/modules/LuckyUser.ts +++ b/packages/features/di/modules/LuckyUser.ts @@ -1,5 +1,5 @@ import { DI_TOKENS } from "@calcom/features/di/tokens"; -import { LuckyUserService } from "@calcom/lib/server/getLuckyUser"; +import { LuckyUserService } from "@calcom/features/bookings/lib/getLuckyUser"; import { bindModuleToClassOnToken, createModule, type ModuleLoader } from "../di"; import { moduleLoader as attributeRepositoryModuleLoader } from "./Attribute"; diff --git a/packages/features/di/modules/QualifiedHosts.ts b/packages/features/di/modules/QualifiedHosts.ts index 3077a3aaee..ceccc5dfeb 100644 --- a/packages/features/di/modules/QualifiedHosts.ts +++ b/packages/features/di/modules/QualifiedHosts.ts @@ -1,5 +1,5 @@ -import type { IQualifiedHostsService } from "@calcom/lib/bookings/findQualifiedHostsWithDelegationCredentials"; -import { QualifiedHostsService } from "@calcom/lib/bookings/findQualifiedHostsWithDelegationCredentials"; +import type { IQualifiedHostsService } from "@calcom/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials"; +import { QualifiedHostsService } from "@calcom/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials"; import { createModule } from "../di"; import { DI_TOKENS } from "../tokens"; diff --git a/packages/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder.ts b/packages/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder.ts index 82bfc947b8..cfc972762c 100644 --- a/packages/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder.ts +++ b/packages/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder.ts @@ -1,6 +1,6 @@ import type { FormResponse, Fields } from "@calcom/app-store/routing-forms/types/types"; import { zodRoutes } from "@calcom/app-store/routing-forms/zod"; -import { acrossQueryValueCompatiblity } from "@calcom/lib/raqb/raqbUtils"; +import { acrossQueryValueCompatiblity } from "@calcom/app-store/_utils/raqb/raqbUtils"; import { withReporting } from "@calcom/lib/sentryWrapper"; import { getUsersAttributes } from "@calcom/lib/service/attribute/server/getAttributes"; import prisma from "@calcom/prisma"; diff --git a/packages/features/ee/round-robin/roundRobinManualReassignment.ts b/packages/features/ee/round-robin/roundRobinManualReassignment.ts index 11b1221c7f..e197f0d7e6 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 { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; import { @@ -8,6 +9,7 @@ import { sendRoundRobinScheduledEmailsAndSMS, sendRoundRobinUpdatedEmailsAndSMS, } from "@calcom/emails"; +import EventManager from "@calcom/features/bookings/lib/EventManager"; import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials"; import getBookingResponsesSchema from "@calcom/features/bookings/lib/getBookingResponsesSchema"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; @@ -23,9 +25,7 @@ import { import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler"; import { getEventName } from "@calcom/features/eventtypes/lib/eventNaming"; import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser"; -import EventManager from "@calcom/features/bookings/lib/EventManager"; import { SENDER_NAME } from "@calcom/lib/constants"; -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server"; import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService"; import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj"; diff --git a/packages/features/ee/round-robin/roundRobinReassignment.ts b/packages/features/ee/round-robin/roundRobinReassignment.ts index 380fc01572..af5eaa304d 100644 --- a/packages/features/ee/round-robin/roundRobinReassignment.ts +++ b/packages/features/ee/round-robin/roundRobinReassignment.ts @@ -1,6 +1,10 @@ // eslint-disable-next-line no-restricted-imports import { cloneDeep } from "lodash"; +import { + enrichHostsWithDelegationCredentials, + enrichUserWithDelegationCredentialsIncludeServiceAccountKey, +} from "@calcom/app-store/delegationCredential"; import { OrganizerDefaultConferencingAppType, getLocationValueForDB } from "@calcom/app-store/locations"; import { eventTypeAppMetadataOptionalSchema } from "@calcom/app-store/zod-utils"; import dayjs from "@calcom/dayjs"; @@ -9,22 +13,18 @@ import { sendRoundRobinScheduledEmailsAndSMS, sendRoundRobinUpdatedEmailsAndSMS, } from "@calcom/emails"; +import EventManager from "@calcom/features/bookings/lib/EventManager"; import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials"; import getBookingResponsesSchema from "@calcom/features/bookings/lib/getBookingResponsesSchema"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; import { ensureAvailableUsers } from "@calcom/features/bookings/lib/handleNewBooking/ensureAvailableUsers"; import { getEventTypesFromDB } from "@calcom/features/bookings/lib/handleNewBooking/getEventTypesFromDB"; import type { IsFixedAwareUser } from "@calcom/features/bookings/lib/handleNewBooking/types"; +import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import AssignmentReasonRecorder, { RRReassignmentType, } from "@calcom/features/ee/round-robin/assignmentReason/AssignmentReasonRecorder"; import { getEventName } from "@calcom/features/eventtypes/lib/eventNaming"; -import EventManager from "@calcom/features/bookings/lib/EventManager"; -import { - enrichHostsWithDelegationCredentials, - enrichUserWithDelegationCredentialsIncludeServiceAccountKey, -} from "@calcom/lib/delegationCredential/server"; -import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import { ErrorCode } from "@calcom/lib/errorCodes"; import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService"; import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj"; diff --git a/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts b/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts index e499bdf89a..18b17a3d0d 100644 --- a/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts +++ b/packages/features/noShow/handleSendingAttendeeNoShowDataToApps.ts @@ -2,7 +2,7 @@ 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 CrmManager from "@calcom/features/crmManager/crmManager"; import logger from "@calcom/lib/logger"; import prisma from "@calcom/prisma"; import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; diff --git a/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts b/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts index e685ee1c74..be39032c95 100644 --- a/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts +++ b/packages/features/tasker/tasks/crm/__tests__/createCRMEvent.test.ts @@ -62,7 +62,7 @@ vi.mock("../lib/buildCalendarEvent", () => ({ })); const mockCreateEvent = vi.fn().mockResolvedValue({ id: "sf-event-123" }); -vi.mock("@calcom/lib/crmManager/crmManager", () => ({ +vi.mock("@calcom/features/crmManager/crmManager", () => ({ default: class MockCrmManager { private credential: CRMCredential; diff --git a/packages/features/tasker/tasks/crm/createCRMEvent.ts b/packages/features/tasker/tasks/crm/createCRMEvent.ts index fda24b322b..2292c57300 100644 --- a/packages/features/tasker/tasks/crm/createCRMEvent.ts +++ b/packages/features/tasker/tasks/crm/createCRMEvent.ts @@ -170,7 +170,7 @@ export async function createCRMEvent(payload: string): Promise { continue; } - const CrmManager = (await import("@calcom/lib/crmManager/crmManager")).default; + const CrmManager = (await import("@calcom/features/crmManager/crmManager")).default; const crm = new CrmManager(crmCredential, app); diff --git a/packages/lib/bookings/getRoutedUsers.test.ts b/packages/features/users/lib/getRoutedUsers.test.ts similarity index 100% rename from packages/lib/bookings/getRoutedUsers.test.ts rename to packages/features/users/lib/getRoutedUsers.test.ts diff --git a/packages/lib/bookings/getRoutedUsers.ts b/packages/features/users/lib/getRoutedUsers.ts similarity index 95% rename from packages/lib/bookings/getRoutedUsers.ts rename to packages/features/users/lib/getRoutedUsers.ts index 7511caf5ff..b3c4ea2009 100644 --- a/packages/lib/bookings/getRoutedUsers.ts +++ b/packages/features/users/lib/getRoutedUsers.ts @@ -1,5 +1,7 @@ +import { enrichHostsWithDelegationCredentials } from "@calcom/app-store/delegationCredential"; +import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId"; import logger from "@calcom/lib/logger"; -import { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +import { findTeamMembersMatchingAttributeLogic } from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; import type { AttributesQueryValue } from "@calcom/lib/raqb/types"; import { safeStringify } from "@calcom/lib/safeStringify"; import type { RRResetInterval } from "@calcom/prisma/client"; @@ -7,9 +9,6 @@ import type { RRTimestampBasis } from "@calcom/prisma/enums"; import { SchedulingType } from "@calcom/prisma/enums"; import type { CredentialPayload } from "@calcom/types/Credential"; -import { enrichHostsWithDelegationCredentials } from "../delegationCredential/server"; -import getOrgIdFromMemberOrTeamId from "../getOrgIdFromMemberOrTeamId"; - const log = logger.getSubLogger({ prefix: ["[getRoutedUsers]"] }); export const getRoutedUsersWithContactOwnerAndFixedUsers = < diff --git a/packages/lib/date-ranges.ts b/packages/lib/date-ranges.ts index c453438771..be3d6b566e 100644 --- a/packages/lib/date-ranges.ts +++ b/packages/lib/date-ranges.ts @@ -1,6 +1,6 @@ import type { Dayjs } from "@calcom/dayjs"; import dayjs from "@calcom/dayjs"; -import type { IOutOfOfficeData } from "@calcom/lib/getUserAvailability"; +import type { IOutOfOfficeData } from "@calcom/features/availability/lib/getUserAvailability"; import type { Availability } from "@calcom/prisma/client"; export type DateRange = { diff --git a/packages/lib/delegationCredential/clientAndServer.ts b/packages/lib/delegationCredential.ts similarity index 100% rename from packages/lib/delegationCredential/clientAndServer.ts rename to packages/lib/delegationCredential.ts diff --git a/packages/lib/eslint.config.mjs b/packages/lib/eslint.config.mjs new file mode 100644 index 0000000000..cac9f72e6a --- /dev/null +++ b/packages/lib/eslint.config.mjs @@ -0,0 +1,11 @@ +import { forbid } from "@calcom/eslint-config/base"; +import { config } from "@calcom/eslint-config/base"; + +export default [ + ...config, + forbid({ + from: "../app-store/**", + target: ".", + message: "lib package should not import from app-store to avoid circular dependencies.", + }), +]; diff --git a/packages/lib/intervalLimits/server/getBusyTimesFromLimits.ts b/packages/lib/intervalLimits/server/getBusyTimesFromLimits.ts index 2c0024609f..50aee6ee26 100644 --- a/packages/lib/intervalLimits/server/getBusyTimesFromLimits.ts +++ b/packages/lib/intervalLimits/server/getBusyTimesFromLimits.ts @@ -1,8 +1,8 @@ import type { Dayjs } from "@calcom/dayjs"; import dayjs from "@calcom/dayjs"; +import type { EventType } from "@calcom/features/availability/lib/getUserAvailability"; import { getCheckBookingLimitsService } from "@calcom/features/di/containers/BookingLimits"; import { getBusyTimesService } from "@calcom/features/di/containers/BusyTimes"; -import type { EventType } from "@calcom/lib/getUserAvailability"; import { getPeriodStartDatesBetween } from "@calcom/lib/intervalLimits/utils/getPeriodStartDatesBetween"; import { withReporting } from "@calcom/lib/sentryWrapper"; import { performance } from "@calcom/lib/server/perfObserver"; diff --git a/packages/lib/server/getUsersCredentials.ts b/packages/lib/server/getUsersCredentials.ts deleted file mode 100644 index 34dffc0a6d..0000000000 --- a/packages/lib/server/getUsersCredentials.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { prisma } from "@calcom/prisma"; -import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; - -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "../delegationCredential/server"; - -type User = { id: number; email: string }; - -/** - * It includes in-memory DelegationCredential credentials as well. - */ -export async function getUsersCredentialsIncludeServiceAccountKey(user: User) { - const credentials = await prisma.credential.findMany({ - where: { - userId: user.id, - }, - select: credentialForCalendarServiceSelect, - orderBy: { - id: "asc", - }, - }); - - const { credentials: allCredentials } = await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({ - user: { - email: user.email, - id: user.id, - credentials, - }, - }); - - return allCredentials; -} - -export async function getUsersCredentials(user: User) { - const credentials = await getUsersCredentialsIncludeServiceAccountKey(user); - return credentials.map(({ delegatedTo: _1, ...rest }) => rest); -} diff --git a/packages/lib/server/repository/credential.ts b/packages/lib/server/repository/credential.ts index e08713c948..e5ae810cda 100644 --- a/packages/lib/server/repository/credential.ts +++ b/packages/lib/server/repository/credential.ts @@ -4,7 +4,7 @@ import type { Prisma, PrismaClient } from "@calcom/prisma/client"; import { safeCredentialSelect } from "@calcom/prisma/selects/credential"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; -import { buildNonDelegationCredential } from "../../delegationCredential/server"; +import { buildNonDelegationCredential } from "../../delegationCredential"; const log = logger.getSubLogger({ prefix: ["CredentialRepository"] }); diff --git a/packages/lib/server/repository/user.ts b/packages/lib/server/repository/user.ts index af3fb019b8..852d89c70c 100644 --- a/packages/lib/server/repository/user.ts +++ b/packages/lib/server/repository/user.ts @@ -1,6 +1,7 @@ import type { z } from "zod"; import { whereClauseForOrgWithSlugOrRequestedSlug } from "@calcom/ee/organizations/lib/orgDomains"; +import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; import { getTranslation } from "@calcom/lib/server/i18n"; @@ -15,7 +16,6 @@ import { userMetadata } from "@calcom/prisma/zod-utils"; import type { UpId, UserProfile } from "@calcom/types/UserProfile"; import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "../../availability"; -import { buildNonDelegationCredentials } from "../../delegationCredential/clientAndServer"; import { withSelectedCalendars } from "../withSelectedCalendars"; import { ProfileRepository } from "./profile"; import { getParsedTeam } from "./teamUtils"; diff --git a/packages/lib/slots.ts b/packages/lib/slots.ts index 3ae06df1b5..876f7d26f5 100644 --- a/packages/lib/slots.ts +++ b/packages/lib/slots.ts @@ -1,6 +1,10 @@ import type { Dayjs } from "@calcom/dayjs"; import dayjs from "@calcom/dayjs"; -import type { IFromUser, IOutOfOfficeData, IToUser } from "@calcom/lib/getUserAvailability"; +import type { + IFromUser, + IOutOfOfficeData, + IToUser, +} from "@calcom/features/availability/lib/getUserAvailability"; import { withReporting } from "@calcom/lib/sentryWrapper"; import type { DateRange } from "./date-ranges"; diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx index 65a90e7209..5e20dbf4e7 100644 --- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx +++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx @@ -22,7 +22,7 @@ import { useTimePreferences } from "@calcom/features/bookings/lib"; import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule"; import { getRoutedTeamMemberIdsFromSearchParams } from "@calcom/lib/bookings/getRoutedTeamMemberIdsFromSearchParams"; import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents"; -import type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars"; +import type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; import { localStorage } from "@calcom/lib/webstorage"; import { BookerLayouts } from "@calcom/prisma/zod-utils"; diff --git a/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx b/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx index baa32b4edd..2a796fa6b1 100644 --- a/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx +++ b/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx @@ -4,7 +4,7 @@ import { useState, useEffect, useMemo } from "react"; import { SingleValueComponent } from "@calcom/features/calendars/DestinationCalendarSelector"; import { OptionComponent } from "@calcom/features/calendars/DestinationCalendarSelector"; -import type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars"; +import type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import classNames from "@calcom/ui/classNames"; import { Badge } from "@calcom/ui/components/badge"; diff --git a/packages/platform/atoms/hooks/useConnectedCalendars.tsx b/packages/platform/atoms/hooks/useConnectedCalendars.tsx index 55eb47dc09..c2d797cf10 100644 --- a/packages/platform/atoms/hooks/useConnectedCalendars.tsx +++ b/packages/platform/atoms/hooks/useConnectedCalendars.tsx @@ -1,6 +1,6 @@ import { useQuery } from "@tanstack/react-query"; -import type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars"; +import type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types"; diff --git a/packages/platform/libraries/app-store.ts b/packages/platform/libraries/app-store.ts index 71e8764c8f..f1fbbcc37f 100644 --- a/packages/platform/libraries/app-store.ts +++ b/packages/platform/libraries/app-store.ts @@ -32,7 +32,7 @@ export type { CredentialPayload } from "@calcom/types/Credential"; export { addDelegationCredential }; -export { enrichUserWithDelegationConferencingCredentialsWithoutOrgId } from "@calcom/lib/delegationCredential/server"; +export { enrichUserWithDelegationConferencingCredentialsWithoutOrgId } from "@calcom/app-store/delegationCredential"; export { toggleDelegationCredentialEnabled } from "@calcom/trpc/server/routers/viewer/delegationCredential/toggleEnabled.handler"; export { CalendarAppError, @@ -46,4 +46,4 @@ export { export { DelegationCredentialRepository } from "@calcom/lib/server/repository/delegationCredential"; export { OAuth2UniversalSchema } from "@calcom/app-store/_utils/oauth/universalSchema"; -export { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; +export { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; diff --git a/packages/platform/libraries/bookings.ts b/packages/platform/libraries/bookings.ts index 472bd0a520..8c85e225fb 100644 --- a/packages/platform/libraries/bookings.ts +++ b/packages/platform/libraries/bookings.ts @@ -1,4 +1,3 @@ -export { LuckyUserService } from "@calcom/lib/server/getLuckyUser"; - +export { LuckyUserService } from "@calcom/features/bookings/lib/getLuckyUser"; export { CheckBookingLimitsService } from "@calcom/lib/intervalLimits/server/checkBookingLimits"; export { CheckBookingAndDurationLimitsService } from "@calcom/features/bookings/lib/handleNewBooking/checkBookingAndDurationLimits"; diff --git a/packages/platform/libraries/index.ts b/packages/platform/libraries/index.ts index 3c5e1ee858..05076e8e3b 100644 --- a/packages/platform/libraries/index.ts +++ b/packages/platform/libraries/index.ts @@ -51,7 +51,7 @@ export { handleCreatePhoneCall }; export { handleNewRecurringBooking } from "@calcom/features/bookings/lib/handleNewRecurringBooking"; -export { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars"; +export { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; export { getBusyCalendarTimes } from "@calcom/features/calendars/lib/CalendarManager"; @@ -122,7 +122,7 @@ export { encryptServiceAccountKey } from "@calcom/lib/server/serviceAccountKey"; export { createHandler as createApiKeyHandler } from "@calcom/trpc/server/routers/viewer/apiKeys/create.handler"; export { getCalendarLinks } from "@calcom/features/bookings/lib/getCalendarLinks"; -export { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +export { findTeamMembersMatchingAttributeLogic } from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; export type { TFindTeamMembersMatchingAttributeLogicInputSchema } from "@calcom/trpc/server/routers/viewer/attributes/findTeamMembersMatchingAttributeLogic.schema"; export { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner"; diff --git a/packages/platform/libraries/schedules.ts b/packages/platform/libraries/schedules.ts index c649bb0ed5..ba3967e88f 100644 --- a/packages/platform/libraries/schedules.ts +++ b/packages/platform/libraries/schedules.ts @@ -4,4 +4,4 @@ export { } from "@calcom/lib/server/repository/schedule"; export { updateSchedule, type UpdateScheduleResponse } from "@calcom/lib/schedules/updateSchedule"; -export {UserAvailabilityService} from "@calcom/lib/getUserAvailability" \ No newline at end of file +export { UserAvailabilityService } from "@calcom/features/availability/lib/getUserAvailability"; diff --git a/packages/platform/libraries/slots.ts b/packages/platform/libraries/slots.ts index 94a0dac056..2a1e6ebe3d 100644 --- a/packages/platform/libraries/slots.ts +++ b/packages/platform/libraries/slots.ts @@ -1,5 +1,5 @@ -import { FilterHostsService } from "@calcom/lib/bookings/filterHostsBySameRoundRobinHost"; -import { QualifiedHostsService } from "@calcom/lib/bookings/findQualifiedHostsWithDelegationCredentials"; +import { FilterHostsService } from "@calcom/features/bookings/lib/host-filtering/filterHostsBySameRoundRobinHost"; +import { QualifiedHostsService } from "@calcom/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials"; import { BusyTimesService } from "@calcom/lib/getBusyTimes"; import { NoSlotsNotificationService } from "@calcom/trpc/server/routers/viewer/slots/handleNotificationWhenNoSlots"; import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util"; diff --git a/packages/trpc/server/routers/viewer/apps/appById.handler.ts b/packages/trpc/server/routers/viewer/apps/appById.handler.ts index 2474ca7f48..9b45a322d6 100644 --- a/packages/trpc/server/routers/viewer/apps/appById.handler.ts +++ b/packages/trpc/server/routers/viewer/apps/appById.handler.ts @@ -1,5 +1,5 @@ +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import getApps from "@calcom/app-store/utils"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; import { TRPCError } from "@trpc/server"; diff --git a/packages/trpc/server/routers/viewer/apps/appCredentialsByType.handler.ts b/packages/trpc/server/routers/viewer/apps/appCredentialsByType.handler.ts index abd3a0ce79..31463bd8c1 100644 --- a/packages/trpc/server/routers/viewer/apps/appCredentialsByType.handler.ts +++ b/packages/trpc/server/routers/viewer/apps/appCredentialsByType.handler.ts @@ -1,4 +1,4 @@ -import { getAllDelegationCredentialsForUserByAppType } from "@calcom/lib/delegationCredential/server"; +import { getAllDelegationCredentialsForUserByAppType } from "@calcom/app-store/delegationCredential"; import { UserRepository } from "@calcom/lib/server/repository/user"; import { prisma } from "@calcom/prisma"; import { safeCredentialSelect } from "@calcom/prisma/selects/credential"; diff --git a/packages/trpc/server/routers/viewer/apps/queryForDependencies.handler.ts b/packages/trpc/server/routers/viewer/apps/queryForDependencies.handler.ts index 59b60e4001..19c441953f 100644 --- a/packages/trpc/server/routers/viewer/apps/queryForDependencies.handler.ts +++ b/packages/trpc/server/routers/viewer/apps/queryForDependencies.handler.ts @@ -1,5 +1,5 @@ import { getAppFromSlug } from "@calcom/app-store/utils"; -import { getAllDelegationCredentialsForUserByAppSlug } from "@calcom/lib/delegationCredential/server"; +import { getAllDelegationCredentialsForUserByAppSlug } from "@calcom/app-store/delegationCredential"; import { prisma } from "@calcom/prisma"; import type { TrpcSessionUser } from "../../../types"; diff --git a/packages/trpc/server/routers/viewer/apps/updateUserDefaultConferencingApp.handler.ts b/packages/trpc/server/routers/viewer/apps/updateUserDefaultConferencingApp.handler.ts index 761b596a53..0e83db416d 100644 --- a/packages/trpc/server/routers/viewer/apps/updateUserDefaultConferencingApp.handler.ts +++ b/packages/trpc/server/routers/viewer/apps/updateUserDefaultConferencingApp.handler.ts @@ -1,7 +1,7 @@ import z from "zod"; +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import getApps from "@calcom/app-store/utils"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; import { prisma } from "@calcom/prisma"; import { userMetadata } from "@calcom/prisma/zod-utils"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; diff --git a/packages/trpc/server/routers/viewer/attributes/findTeamMembersMatchingAttributeLogic.handler.ts b/packages/trpc/server/routers/viewer/attributes/findTeamMembersMatchingAttributeLogic.handler.ts index bea65d02da..887509fe1e 100644 --- a/packages/trpc/server/routers/viewer/attributes/findTeamMembersMatchingAttributeLogic.handler.ts +++ b/packages/trpc/server/routers/viewer/attributes/findTeamMembersMatchingAttributeLogic.handler.ts @@ -1,7 +1,7 @@ import type { ServerResponse } from "http"; import type { NextApiResponse } from "next"; -import { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +import { findTeamMembersMatchingAttributeLogic } from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; import { UserRepository } from "@calcom/lib/server/repository/user"; import type { PrismaClient } from "@calcom/prisma"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; diff --git a/packages/trpc/server/routers/viewer/availability/calendarOverlay.handler.ts b/packages/trpc/server/routers/viewer/availability/calendarOverlay.handler.ts index b43960dfe6..bc15baa538 100644 --- a/packages/trpc/server/routers/viewer/availability/calendarOverlay.handler.ts +++ b/packages/trpc/server/routers/viewer/availability/calendarOverlay.handler.ts @@ -1,6 +1,6 @@ +import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import dayjs from "@calcom/dayjs"; import { getBusyCalendarTimes } from "@calcom/features/calendars/lib/CalendarManager"; -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; import { prisma } from "@calcom/prisma"; import type { EventBusyDate } from "@calcom/types/Calendar"; diff --git a/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts b/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts index 5d872cd04d..1abd0682fc 100644 --- a/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts @@ -1,9 +1,9 @@ +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import dayjs from "@calcom/dayjs"; import { sendAddGuestsEmails } from "@calcom/emails"; import EventManager from "@calcom/features/bookings/lib/EventManager"; import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service"; import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; import { getTranslation } from "@calcom/lib/server/i18n"; import { prisma } from "@calcom/prisma"; import { MembershipRole } from "@calcom/prisma/enums"; diff --git a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts b/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts index 2051bf0ddb..428b0961ea 100644 --- a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts @@ -1,3 +1,4 @@ +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import type { LocationObject } from "@calcom/app-store/locations"; import { getLocationValueForDB } from "@calcom/app-store/locations"; import { sendDeclinedEmailsAndSMS } from "@calcom/emails"; @@ -14,7 +15,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 { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; import { getTranslation } from "@calcom/lib/server/i18n"; import { WorkflowService } from "@calcom/lib/server/service/workflows"; import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat"; diff --git a/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts b/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts index 7838b91c56..35f561ac7f 100644 --- a/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts @@ -1,14 +1,14 @@ import type { z } from "zod"; +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import { getEventLocationType, OrganizerDefaultConferencingAppType } from "@calcom/app-store/locations"; import { getAppFromSlug } from "@calcom/app-store/utils"; import { sendLocationChangeEmailsAndSMS } from "@calcom/emails"; -import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser"; import EventManager from "@calcom/features/bookings/lib/EventManager"; +import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser"; import { buildCalEventFromBooking } from "@calcom/lib/buildCalEventFromBooking"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; import { getTranslation } from "@calcom/lib/server/i18n"; import { BookingRepository } from "@calcom/lib/server/repository/booking"; import { CredentialRepository } from "@calcom/lib/server/repository/credential"; diff --git a/packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts b/packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts index 2afdbe1500..5f9fc171e4 100644 --- a/packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts @@ -1,6 +1,9 @@ import type { TFunction } from "i18next"; import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; +import { getDelegationCredentialOrRegularCredential } from "@calcom/app-store/delegationCredential"; +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; +import { deleteMeeting } from "@calcom/app-store/videoClient"; import dayjs from "@calcom/dayjs"; import { sendRequestRescheduleEmailAndSMS } from "@calcom/emails"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; @@ -12,17 +15,14 @@ import { import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload"; import { CalendarEventBuilder } from "@calcom/lib/builders/CalendarEvent/builder"; import { CalendarEventDirector } from "@calcom/lib/builders/CalendarEvent/director"; -import { getDelegationCredentialOrRegularCredential } from "@calcom/lib/delegationCredential/server"; import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server"; import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId"; import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; import { getTranslation } from "@calcom/lib/server/i18n"; import { WorkflowRepository } from "@calcom/lib/server/repository/workflow"; import { BookingWebhookFactory } from "@calcom/lib/server/service/BookingWebhookFactory"; -import { deleteMeeting } from "@calcom/app-store/videoClient"; import { prisma } from "@calcom/prisma"; import type { BookingReference, EventType } from "@calcom/prisma/client"; import type { WebhookTriggerEvents } from "@calcom/prisma/enums"; diff --git a/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts b/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts index 3e4b22757d..98bf888615 100644 --- a/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts +++ b/packages/trpc/server/routers/viewer/calendars/connectedCalendars.handler.ts @@ -1,5 +1,5 @@ import { CalendarCacheRepository } from "@calcom/features/calendar-cache/calendar-cache.repository"; -import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars"; +import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars"; import { prisma } from "@calcom/prisma"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; diff --git a/packages/trpc/server/routers/viewer/calendars/setDestinationCalendar.handler.ts b/packages/trpc/server/routers/viewer/calendars/setDestinationCalendar.handler.ts index d7cbe3a7a1..365f6414ff 100644 --- a/packages/trpc/server/routers/viewer/calendars/setDestinationCalendar.handler.ts +++ b/packages/trpc/server/routers/viewer/calendars/setDestinationCalendar.handler.ts @@ -1,5 +1,8 @@ -import { getCalendarCredentials, getConnectedCalendars } from "@calcom/features/calendars/lib/CalendarManager"; -import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials"; +import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; +import { + getCalendarCredentials, + getConnectedCalendars, +} from "@calcom/features/calendars/lib/CalendarManager"; import { DestinationCalendarRepository } from "@calcom/lib/server/repository/destinationCalendar"; import { prisma } from "@calcom/prisma"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; diff --git a/packages/trpc/server/routers/viewer/delegationCredential/toggleEnabled.handler.ts b/packages/trpc/server/routers/viewer/delegationCredential/toggleEnabled.handler.ts index 5b0e632679..e9b9efec21 100644 --- a/packages/trpc/server/routers/viewer/delegationCredential/toggleEnabled.handler.ts +++ b/packages/trpc/server/routers/viewer/delegationCredential/toggleEnabled.handler.ts @@ -1,7 +1,7 @@ import type { z } from "zod"; import { sendDelegationCredentialDisabledEmail } from "@calcom/emails/email-manager"; -import { checkIfSuccessfullyConfiguredInWorkspace } from "@calcom/lib/delegationCredential/server"; +import { checkIfSuccessfullyConfiguredInWorkspace } from "@calcom/app-store/delegationCredential"; import logger from "@calcom/lib/logger"; import { getTranslation } from "@calcom/lib/server/i18n"; import { DelegationCredentialRepository } from "@calcom/lib/server/repository/delegationCredential"; diff --git a/packages/trpc/server/routers/viewer/me/getUserTopBanners.handler.ts b/packages/trpc/server/routers/viewer/me/getUserTopBanners.handler.ts index 16510e3790..93a0070e92 100644 --- a/packages/trpc/server/routers/viewer/me/getUserTopBanners.handler.ts +++ b/packages/trpc/server/routers/viewer/me/getUserTopBanners.handler.ts @@ -1,5 +1,8 @@ -import { getCalendarCredentials, getConnectedCalendars } from "@calcom/features/calendars/lib/CalendarManager"; -import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential/server"; +import { + getCalendarCredentials, + getConnectedCalendars, +} from "@calcom/features/calendars/lib/CalendarManager"; +import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential"; import { prisma } from "@calcom/prisma"; import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; import type { TrpcSessionUser } from "@calcom/trpc/server/types"; diff --git a/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts b/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts index ab5924c805..a39b2df7ed 100644 --- a/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts +++ b/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts @@ -6,13 +6,13 @@ import type { ServerResponse } from "http"; import type { NextApiResponse } from "next"; +import { enrichHostsWithDelegationCredentials } from "@calcom/app-store/delegationCredential"; import { enrichFormWithMigrationData } from "@calcom/app-store/routing-forms/enrichFormWithMigrationData"; import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import { getUrlSearchParamsToForwardForTestPreview } from "@calcom/features/routing-forms/lib/getUrlSearchParamsToForward"; -import { enrichHostsWithDelegationCredentials } from "@calcom/lib/delegationCredential/server"; import { entityPrismaWhereClause } from "@calcom/lib/entityPermissionUtils.server"; import { fromEntriesWithDuplicateKeys } from "@calcom/lib/fromEntriesWithDuplicateKeys"; -import { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; +import { findTeamMembersMatchingAttributeLogic } from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic"; import { EventTypeRepository } from "@calcom/lib/server/repository/eventTypeRepository"; import { UserRepository } from "@calcom/lib/server/repository/user"; import type { PrismaClient } from "@calcom/prisma"; diff --git a/packages/trpc/server/routers/viewer/slots/util.ts b/packages/trpc/server/routers/viewer/slots/util.ts index 31924f71c2..9023a40d4a 100644 --- a/packages/trpc/server/routers/viewer/slots/util.ts +++ b/packages/trpc/server/routers/viewer/slots/util.ts @@ -5,20 +5,6 @@ import { v4 as uuid } from "uuid"; import type { Dayjs } from "@calcom/dayjs"; import dayjs from "@calcom/dayjs"; import { orgDomainConfig } from "@calcom/ee/organizations/lib/orgDomains"; -import { checkForConflicts } from "@calcom/features/bookings/lib/conflictChecker/checkForConflicts"; -import { isEventTypeLoggingEnabled } from "@calcom/features/bookings/lib/isEventTypeLoggingEnabled"; -import type { CacheService } from "@calcom/features/calendar-cache/lib/getShouldServeCache"; -import type { FeaturesRepository } from "@calcom/features/flags/features.repository"; -import type { IRedisService } from "@calcom/features/redis/IRedisService"; -import type { QualifiedHostsService } from "@calcom/lib/bookings/findQualifiedHostsWithDelegationCredentials"; -import { shouldIgnoreContactOwner } from "@calcom/lib/bookings/routing/utils"; -import { RESERVED_SUBDOMAINS } from "@calcom/lib/constants"; -import { buildDateRanges } from "@calcom/lib/date-ranges"; -import { getUTCOffsetByTimezone } from "@calcom/lib/dayjs"; -import { getDefaultEvent } from "@calcom/features/eventtypes/lib/defaultEvents"; -import type { getBusyTimesService } from "@calcom/features/di/containers/BusyTimes"; -import { getAggregatedAvailability } from "@calcom/lib/getAggregatedAvailability"; -import type { BusyTimesService } from "@calcom/lib/getBusyTimes"; import type { CurrentSeats, EventType, @@ -26,7 +12,21 @@ import type { UserAvailabilityService, IFromUser, IToUser, -} from "@calcom/lib/getUserAvailability"; +} from "@calcom/features/availability/lib/getUserAvailability"; +import { checkForConflicts } from "@calcom/features/bookings/lib/conflictChecker/checkForConflicts"; +import type { QualifiedHostsService } from "@calcom/features/bookings/lib/host-filtering/findQualifiedHostsWithDelegationCredentials"; +import { isEventTypeLoggingEnabled } from "@calcom/features/bookings/lib/isEventTypeLoggingEnabled"; +import type { CacheService } from "@calcom/features/calendar-cache/lib/getShouldServeCache"; +import type { getBusyTimesService } from "@calcom/features/di/containers/BusyTimes"; +import { getDefaultEvent } from "@calcom/features/eventtypes/lib/defaultEvents"; +import type { FeaturesRepository } from "@calcom/features/flags/features.repository"; +import type { IRedisService } from "@calcom/features/redis/IRedisService"; +import { shouldIgnoreContactOwner } from "@calcom/lib/bookings/routing/utils"; +import { RESERVED_SUBDOMAINS } from "@calcom/lib/constants"; +import { buildDateRanges } from "@calcom/lib/date-ranges"; +import { getUTCOffsetByTimezone } from "@calcom/lib/dayjs"; +import { getAggregatedAvailability } from "@calcom/lib/getAggregatedAvailability"; +import type { BusyTimesService } from "@calcom/lib/getBusyTimes"; import { descendingLimitKeys, intervalLimitKeyToUnit } from "@calcom/lib/intervalLimits/intervalLimit"; import type { IntervalLimit } from "@calcom/lib/intervalLimits/intervalLimitSchema"; import { parseBookingLimit } from "@calcom/lib/intervalLimits/isBookingLimits"; diff --git a/packages/trpc/server/routers/viewer/teams/getMemberAvailability.handler.ts b/packages/trpc/server/routers/viewer/teams/getMemberAvailability.handler.ts index 6cd3936d90..dbdbb0839a 100644 --- a/packages/trpc/server/routers/viewer/teams/getMemberAvailability.handler.ts +++ b/packages/trpc/server/routers/viewer/teams/getMemberAvailability.handler.ts @@ -1,4 +1,4 @@ -import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server"; +import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential"; import { getUserAvailabilityService } from "@calcom/features/di/containers/GetUserAvailability"; import { isTeamMember } from "@calcom/features/ee/teams/lib/queries"; import { MembershipRepository } from "@calcom/lib/server/repository/membership"; diff --git a/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts b/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts index 0aef89fda8..534b954528 100644 --- a/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts +++ b/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts @@ -1,7 +1,7 @@ import dayjs from "@calcom/dayjs"; import { ensureAvailableUsers } from "@calcom/features/bookings/lib/handleNewBooking/ensureAvailableUsers"; import type { IsFixedAwareUser } from "@calcom/features/bookings/lib/handleNewBooking/types"; -import { enrichUsersWithDelegationCredentials } from "@calcom/lib/delegationCredential/server"; +import { enrichUsersWithDelegationCredentials } from "@calcom/app-store/delegationCredential"; import { ErrorCode } from "@calcom/lib/errorCodes"; import logger from "@calcom/lib/logger"; import { withSelectedCalendars } from "@calcom/lib/server/repository/user"; diff --git a/vitest.workspace.ts b/vitest.workspace.ts index 88655c9676..498e907eef 100644 --- a/vitest.workspace.ts +++ b/vitest.workspace.ts @@ -136,10 +136,20 @@ const workspaces = packagedEmbedTestsOnly globals: true, name: "@calcom/app-store-core", include: ["packages/app-store/*.{test,spec}.[jt]s?(x)"], + exclude: ["packages/app-store/delegationCredential.test.ts"], environment: "jsdom", setupFiles: ["packages/ui/components/test-setup.tsx"], }, }, + { + test: { + globals: true, + name: "@calcom/app-store-delegation-credential", + include: ["packages/app-store/delegationCredential.test.ts"], + environment: "node", + setupFiles: ["setupVitest.ts"], + }, + }, { test: { globals: true,