refactor: Migrate repositories/services from /lib to /features (#25925)

* deployment

* update imports

* booking report

* update import paths

* watch list

* watch list

* api key

* api key

* selected slots

* wip

* event type translation

* work flow step

* booking reference

* fix tests

* fix

* fix

* migrate

* wip

* address

* fix
This commit is contained in:
Benny Joo
2025-12-17 14:14:50 +00:00
committed by GitHub
parent aaaff0705b
commit cb7844fd22
69 changed files with 197 additions and 162 deletions
+5 -5
View File
@@ -11,9 +11,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { ILicenseKeyService } from "@calcom/ee/common/server/LicenseKeyService";
import LicenseKeyService, { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { PrismaApiKeyRepository } from "@calcom/lib/server/repository/PrismaApiKeyRepository";
import type { IDeploymentRepository } from "@calcom/lib/server/repository/deployment.interface";
import { ApiKeyService } from "@calcom/lib/server/service/ApiKeyService";
import { PrismaApiKeyRepository } from "@calcom/features/ee/api-keys/repositories/PrismaApiKeyRepository";
import { ApiKeyService } from "@calcom/features/ee/api-keys/services/ApiKeyService";
import type { IDeploymentRepository } from "@calcom/features/ee/deployment/repositories/IDeploymentRepository";
import { UserPermissionRole } from "@calcom/prisma/enums";
import { isAdminGuard } from "../utils/isAdmin";
@@ -21,11 +21,11 @@ import { isLockedOrBlocked } from "../utils/isLockedOrBlocked";
import { ScopeOfAdmin } from "../utils/scopeOfAdmin";
import { verifyApiKey } from "./verifyApiKey";
vi.mock("@calcom/lib/server/service/ApiKeyService", () => ({
vi.mock("@calcom/features/ee/api-keys/services/ApiKeyService", () => ({
ApiKeyService: vi.fn(),
}));
vi.mock("@calcom/lib/server/repository/PrismaApiKeyRepository", () => ({
vi.mock("@calcom/features/ee/api-keys/repositories/PrismaApiKeyRepository", () => ({
PrismaApiKeyRepository: vi.fn(),
}));
+3 -3
View File
@@ -2,10 +2,10 @@ import type { NextMiddleware } from "next-api-middleware";
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys";
import { PrismaApiKeyRepository } from "@calcom/features/ee/api-keys/repositories/PrismaApiKeyRepository";
import { ApiKeyService } from "@calcom/features/ee/api-keys/services/ApiKeyService";
import { DeploymentRepository } from "@calcom/features/ee/deployment/repositories/DeploymentRepository";
import { IS_PRODUCTION } from "@calcom/lib/constants";
import { PrismaApiKeyRepository } from "@calcom/lib/server/repository/PrismaApiKeyRepository";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import { ApiKeyService } from "@calcom/lib/server/service/ApiKeyService";
import { prisma } from "@calcom/prisma";
import { isAdminGuard } from "../utils/isAdmin";
@@ -4,8 +4,8 @@ import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { PrismaApiKeyRepository } from "@calcom/features/ee/api-keys/repositories/PrismaApiKeyRepository";
import { APP_NAME } from "@calcom/lib/constants";
import { PrismaApiKeyRepository } from "@calcom/lib/server/repository/PrismaApiKeyRepository";
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
@@ -1,7 +1,7 @@
import { BookingReferenceRepository } from "@calcom/features/bookingReference/repositories/BookingReferenceRepository";
import { HttpError } from "@calcom/lib/http-error";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { BookingReferenceRepository } from "@calcom/lib/server/repository/bookingReference";
const log = logger.getSubLogger({ prefix: ["daily-video-webhook-handler"] });
@@ -3,7 +3,7 @@ import type { GetServerSidePropsContext } from "next";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { LicenseKeySingleton } from "@calcom/features/ee/common/server/LicenseKeyService";
import { getDeploymentKey } from "@calcom/features/ee/deployment/lib/getDeploymentKey";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import { DeploymentRepository } from "@calcom/features/ee/deployment/repositories/DeploymentRepository";
import prisma from "@calcom/prisma";
import { UserPermissionRole } from "@calcom/prisma/enums";
@@ -1,7 +1,7 @@
import { waitUntil } from "@vercel/functions";
import { UsageEvent, LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import type { IDeploymentRepository } from "@calcom/lib/server/repository/deployment.interface";
import type { IDeploymentRepository } from "@calcom/features/ee/deployment/repositories/IDeploymentRepository";
import { Prisma } from "@calcom/prisma/client";
import type { PrismaClient } from "@calcom/prisma/client";
@@ -4,11 +4,11 @@ import type { AuthOptions, Session } from "next-auth";
import { getToken } from "next-auth/jwt";
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { DeploymentRepository } from "@calcom/features/ee/deployment/repositories/DeploymentRepository";
import { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import prisma from "@calcom/prisma";
const log = logger.getSubLogger({ prefix: ["getServerSession"] });
@@ -13,6 +13,7 @@ import { updateProfilePhotoGoogle } from "@calcom/app-store/_utils/oauth/updateP
import GoogleCalendarService from "@calcom/app-store/googlecalendar/lib/CalendarService";
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { CredentialRepository } from "@calcom/features/credentials/repositories/CredentialRepository";
import { DeploymentRepository } from "@calcom/features/ee/deployment/repositories/DeploymentRepository";
import createUsersAndConnectToOrg from "@calcom/features/ee/dsync/lib/users/createUsersAndConnectToOrg";
import ImpersonationProvider from "@calcom/features/ee/impersonation/lib/ImpersonationProvider";
import { getOrganizationRepository } from "@calcom/features/ee/organizations/di/OrganizationRepository.container";
@@ -36,7 +37,6 @@ import logger from "@calcom/lib/logger";
import { randomString } from "@calcom/lib/random";
import { safeStringify } from "@calcom/lib/safeStringify";
import { hashEmail } from "@calcom/lib/server/PiiHasher";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import slugify from "@calcom/lib/slugify";
import prisma from "@calcom/prisma";
import type { Membership, Team } from "@calcom/prisma/client";
@@ -1,9 +1,10 @@
import { describe, it, expect, beforeAll, afterAll, afterEach } from "vitest";
import { BookingReferenceRepository } from "@calcom/lib/server/repository/bookingReference";
import prisma from "@calcom/prisma";
import type { Booking, Credential, User } from "@calcom/prisma/client";
import { BookingReferenceRepository } from "./BookingReferenceRepository";
describe("BookingReferenceRepository Integration Tests", () => {
let testUser: User;
let testCredential: Credential;
@@ -3,8 +3,8 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import type { PrismaClient } from "@calcom/prisma";
import { BookingReportReason } from "@calcom/prisma/enums";
import { PrismaBookingReportRepository } from "./bookingReport";
import type { CreateBookingReportInput } from "./bookingReport.interface";
import type { CreateBookingReportInput } from "./IBookingReportRepository";
import { PrismaBookingReportRepository } from "./PrismaBookingReportRepository";
vi.mock("@sentry/nextjs", () => ({
captureException: vi.fn(),
@@ -7,7 +7,7 @@ import type {
CreateBookingReportInput,
BookingReportWithDetails,
ListBookingReportsFilters,
} from "./bookingReport.interface";
} from "./IBookingReportRepository";
export class PrismaBookingReportRepository implements IBookingReportRepository {
constructor(private readonly prismaClient: PrismaClient) {}
@@ -1,13 +1,13 @@
import { isValidPhoneNumber } from "libphonenumber-js/max";
import { v4 as uuidv4 } from "uuid";
import { PrismaApiKeyRepository } from "@calcom/features/ee/api-keys/repositories/PrismaApiKeyRepository";
import { replaceEventTypePlaceholders } from "@calcom/features/ee/workflows/components/agent-configuration/utils/promptUtils";
import { EventTypeRepository } from "@calcom/features/eventtypes/repositories/eventTypeRepository";
import { RETELL_AI_TEST_MODE, RETELL_AI_TEST_EVENT_TYPE_MAP } from "@calcom/lib/constants";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
import { HttpError } from "@calcom/lib/http-error";
import logger from "@calcom/lib/logger";
import { PrismaApiKeyRepository } from "@calcom/lib/server/repository/PrismaApiKeyRepository";
import prisma from "@calcom/prisma";
import type {
@@ -1,7 +1,7 @@
import type { PrismaClient as PrismaClientWithExtensions } from "@calcom/prisma";
import type { PrismaClient as PrismaClientWithoutExtensions } from "@calcom/prisma/client";
import type { IDeploymentRepository } from "./deployment.interface";
import type { IDeploymentRepository } from "./IDeploymentRepository";
export class DeploymentRepository implements IDeploymentRepository {
constructor(private prisma: PrismaClientWithoutExtensions | PrismaClientWithExtensions) {}
@@ -1,5 +1,5 @@
import { DI_TOKENS } from "@calcom/features/di/tokens";
import { PrismaSelectedSlotRepository } from "@calcom/lib/server/repository/PrismaSelectedSlotRepository";
import { PrismaSelectedSlotRepository } from "@calcom/features/selectedSlots/repositories/PrismaSelectedSlotRepository";
import { createModule } from "../di";
@@ -1,9 +1,11 @@
import { createContainer } from "@evyweb/ioctopus";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import { moduleLoader as prismaModuleLoader } from "@calcom/features/di/modules/Prisma";
import { moduleLoader as loggerModuleLoader } from "@calcom/features/di/shared/services/logger.service";
import { taskerServiceModule } from "@calcom/features/di/shared/services/tasker.service";
import { SHARED_TOKENS } from "@calcom/features/di/shared/shared.tokens";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import {
createWatchlistFeature,
@@ -11,6 +13,7 @@ import {
} from "@calcom/features/watchlist/lib/facade/WatchlistFeature";
import type { IGlobalWatchlistRepository } from "@calcom/features/watchlist/lib/interface/IWatchlistRepositories";
import type { IOrganizationWatchlistRepository } from "@calcom/features/watchlist/lib/interface/IWatchlistRepositories";
import { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import { AdminWatchlistOperationsService } from "@calcom/features/watchlist/lib/service/AdminWatchlistOperationsService";
import { AdminWatchlistQueryService } from "@calcom/features/watchlist/lib/service/AdminWatchlistQueryService";
import type { GlobalBlockingService } from "@calcom/features/watchlist/lib/service/GlobalBlockingService";
@@ -19,10 +22,7 @@ import { OrganizationWatchlistOperationsService } from "@calcom/features/watchli
import { OrganizationWatchlistQueryService } from "@calcom/features/watchlist/lib/service/OrganizationWatchlistQueryService";
import type { WatchlistAuditService } from "@calcom/features/watchlist/lib/service/WatchlistAuditService";
import type { WatchlistService } from "@calcom/features/watchlist/lib/service/WatchlistService";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import { prisma } from "@calcom/prisma";
import { moduleLoader as prismaModuleLoader } from "@calcom/features/di/modules/Prisma";
import { WATCHLIST_DI_TOKENS } from "../Watchlist.tokens";
import { watchlistModule } from "../modules/Watchlist.module";
@@ -1,8 +1,9 @@
import { v4 as uuidv4 } from "uuid";
import { generateUniqueAPIKey as generateHashedApiKey } from "@calcom/ee/api-keys/lib/apiKeys";
import type { PrismaClient } from "@calcom/prisma";
import { generateUniqueAPIKey as generateHashedApiKey } from "../lib/apiKeys";
export class PrismaApiKeyRepository {
constructor(private prismaClient: PrismaClient) {}
@@ -1,4 +1,4 @@
import type { PrismaApiKeyRepository } from "../repository/PrismaApiKeyRepository";
import type { PrismaApiKeyRepository } from "../repositories/PrismaApiKeyRepository";
type Deps = {
apiKeyRepo: PrismaApiKeyRepository;
@@ -4,9 +4,9 @@ import {
getDeploymentKey,
getDeploymentSignatureToken,
} from "@calcom/features/ee/deployment/lib/getDeploymentKey";
import type { IDeploymentRepository } from "@calcom/features/ee/deployment/repositories/IDeploymentRepository";
import { CALCOM_PRIVATE_API_ROUTE } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import type { IDeploymentRepository } from "@calcom/lib/server/repository/deployment.interface";
import { generateNonce, createSignature } from "./private-api-utils";
@@ -1,6 +1,6 @@
import type { IDeploymentRepository } from "@calcom/features/ee/deployment/repositories/IDeploymentRepository";
import { symmetricDecrypt } from "@calcom/lib/crypto";
import logger from "@calcom/lib/logger";
import type { IDeploymentRepository } from "@calcom/lib/server/repository/deployment.interface";
const log = logger.getSubLogger({ prefix: ["getDeploymentKey"] });
@@ -0,0 +1,25 @@
import type { PrismaClient as PrismaClientWithExtensions } from "@calcom/prisma";
import type { PrismaClient as PrismaClientWithoutExtensions } from "@calcom/prisma/client";
import type { IDeploymentRepository } from "./IDeploymentRepository";
export class DeploymentRepository implements IDeploymentRepository {
constructor(private prisma: PrismaClientWithoutExtensions | PrismaClientWithExtensions) {}
async getLicenseKeyWithId(id: number): Promise<string | null> {
// This repository is special as it is used within prisma extensions
const deployment = await (this.prisma as PrismaClientWithoutExtensions).deployment.findUnique({
where: { id },
select: { licenseKey: true },
});
return deployment?.licenseKey || null;
}
async getSignatureToken(id: number): Promise<string | null> {
const deployment = await (this.prisma as PrismaClientWithoutExtensions).deployment.findUnique({
where: { id },
select: { signatureTokenEncrypted: true },
});
return deployment?.signatureTokenEncrypted || null;
}
}
@@ -0,0 +1,4 @@
export interface IDeploymentRepository {
getLicenseKeyWithId(id: number): Promise<string | null>;
getSignatureToken(id: number): Promise<string | null>;
}
@@ -1,4 +1,5 @@
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { DeploymentRepository } from "@calcom/features/ee/deployment/repositories/DeploymentRepository";
import { getOrganizationRepository } from "@calcom/features/ee/organizations/di/OrganizationRepository.container";
import { findUserToBeOrgOwner } from "@calcom/features/ee/organizations/lib/server/orgCreationUtils";
import { OrganizationOnboardingRepository } from "@calcom/features/organizations/repositories/OrganizationOnboardingRepository";
@@ -6,7 +7,6 @@ import { IS_SELF_HOSTED } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { getTranslation } from "@calcom/lib/server/i18n";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import { prisma } from "@calcom/prisma";
import type { Team, User } from "@calcom/prisma/client";
import { BillingPeriod } from "@calcom/prisma/enums";
@@ -5,7 +5,7 @@ import { describe, it, expect, beforeEach, vi } from "vitest";
import { OrganizationRepository } from "@calcom/features/ee/organizations/repositories/OrganizationRepository";
import type { Prisma } from "@calcom/prisma/client";
vi.mock("@calcom/lib/server/repository/teamUtils", () => ({
vi.mock("@calcom/features/ee/teams/lib/getParsedTeam", () => ({
getParsedTeam: <T>(org: T) => org,
}));
@@ -1,11 +1,11 @@
import type { z } from "zod";
import { getOrgUsernameFromEmail } from "@calcom/features/auth/signup/utils/getOrgUsernameFromEmail";
import { getParsedTeam } from "@calcom/features/ee/teams/lib/getParsedTeam";
import { createAProfileForAnExistingUser } from "@calcom/features/profile/lib/createAProfileForAnExistingUser";
import { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { getParsedTeam } from "@calcom/lib/server/repository/teamUtils";
import type { PrismaClient } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
import type { CreationSource } from "@calcom/prisma/enums";
@@ -1,19 +1,19 @@
import { metadata as GoogleMeetMetadata } from "@calcom/app-store/googlevideo/_metadata";
import { MeetLocationType } from "@calcom/app-store/locations";
import getICalUID from "@calcom/emails/lib/getICalUID";
import { BookingReferenceRepository } from "@calcom/features/bookingReference/repositories/BookingReferenceRepository";
import EventManager from "@calcom/features/bookings/lib/EventManager";
import type { EventManagerInitParams } from "@calcom/features/bookings/lib/EventManager";
import { getAllCredentialsIncludeServiceAccountKey } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import type { EventType } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getVideoCallDetails } from "@calcom/features/bookings/lib/handleNewBooking/getVideoCallDetails";
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
import EventManager from "@calcom/features/bookings/lib/EventManager";
import type { EventManagerInitParams } from "@calcom/features/bookings/lib/EventManager";
import logger from "@calcom/lib/logger";
import { getTranslation } from "@calcom/lib/server/i18n";
import { BookingReferenceRepository } from "@calcom/lib/server/repository/bookingReference";
import { prisma } from "@calcom/prisma";
import type { DestinationCalendar } from "@calcom/prisma/client";
import type { Prisma } from "@calcom/prisma/client";
import type { CalendarEvent, AdditionalInformation } from "@calcom/types/Calendar";
import getICalUID from "@calcom/emails/lib/getICalUID";
type InitParams = {
user: {
@@ -165,9 +165,9 @@ export const handleRescheduleEventManager = async ({
const calendarResult = results.find((result) => result.type.includes("_calendar"));
if (changedOrganizer) {
const providerICalUID = evt.iCalUID = Array.isArray(calendarResult?.createdEvent)
const providerICalUID = (evt.iCalUID = Array.isArray(calendarResult?.createdEvent)
? calendarResult?.createdEvent[0]?.iCalUID
: calendarResult?.createdEvent?.iCalUID;
: calendarResult?.createdEvent?.iCalUID);
evt.iCalUID = providerICalUID || getICalUID({});
} else {
evt.iCalUID = Array.isArray(calendarResult?.updatedEvent)
@@ -1,8 +1,8 @@
import type { z } from "zod";
import { whereClauseForOrgWithSlugOrRequestedSlug } from "@calcom/ee/organizations/lib/orgDomains";
import { getParsedTeam } from "@calcom/features/ee/teams/lib/getParsedTeam";
import logger from "@calcom/lib/logger";
import { getParsedTeam } from "@calcom/lib/server/repository/teamUtils";
import type { PrismaClient } from "@calcom/prisma";
import { prisma } from "@calcom/prisma";
import type { Prisma } from "@calcom/prisma/client";
@@ -1,7 +1,7 @@
import { vi, describe, it, expect, beforeEach } from "vitest";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { isOrganisationAdmin, isOrganisationOwner } from "@calcom/lib/server/queries/organisations";
import { isOrganisationAdmin, isOrganisationOwner } from "@calcom/features/pbac/utils/isOrganisationAdmin";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -24,7 +24,7 @@ vi.mock("@calcom/prisma", () => ({
},
},
}));
vi.mock("@calcom/lib/server/queries/organisations", () => ({
vi.mock("@calcom/features/pbac/utils/isOrganisationAdmin", () => ({
isOrganisationAdmin: vi.fn(),
isOrganisationOwner: vi.fn(),
}));
@@ -1,5 +1,5 @@
import { isTeamOwner } from "@calcom/features/ee/teams/lib/queries";
import { isOrganisationAdmin, isOrganisationOwner } from "@calcom/lib/server/queries/organisations";
import { isOrganisationAdmin, isOrganisationOwner } from "@calcom/features/pbac/utils/isOrganisationAdmin";
import { prisma } from "@calcom/prisma";
import type { Membership } from "@calcom/prisma/client";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -1,4 +1,4 @@
import prisma from "@calcom/prisma";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
// export type OrganisationWithMembers = Awaited<ReturnType<typeof getOrganizationMembers>>;
@@ -2,11 +2,12 @@ import prismock from "../../../../tests/libs/__mocks__/prisma";
import { describe, it, expect, beforeEach, vi } from "vitest";
import { ProfileRepository, LookupTarget } from "./ProfileRepository";
import { MembershipRole } from "@calcom/prisma/enums";
import type { Prisma } from "@calcom/prisma/client";
import { MembershipRole } from "@calcom/prisma/enums";
vi.mock("@calcom/lib/server/repository/teamUtils", () => ({
import { ProfileRepository, LookupTarget } from "./ProfileRepository";
vi.mock("@calcom/features/ee/teams/lib/getParsedTeam", () => ({
getParsedTeam: <T>(org: T) => org,
}));
@@ -478,4 +479,3 @@ describe("ProfileRepository.findByUpIdWithAuth - IDOR Security Fix", () => {
});
});
});
@@ -2,10 +2,10 @@ import { v4 as uuidv4 } from "uuid";
import { whereClauseForOrgWithSlugOrRequestedSlug } from "@calcom/ee/organizations/lib/orgDomains";
import { getOrgUsernameFromEmail } from "@calcom/features/auth/signup/utils/getOrgUsernameFromEmail";
import { getParsedTeam } from "@calcom/features/ee/teams/lib/getParsedTeam";
import { DATABASE_CHUNK_SIZE } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { getParsedTeam } from "@calcom/lib/server/repository/teamUtils";
import prisma from "@calcom/prisma";
import type { User as PrismaUser } from "@calcom/prisma/client";
import type { Prisma } from "@calcom/prisma/client";
@@ -1,8 +1,8 @@
import { z } from "zod";
import { EventTypeTranslationRepository } from "@calcom/features/eventTypeTranslation/repositories/EventTypeTranslationRepository";
import { locales as i18nLocales } from "@calcom/lib/i18n";
import logger from "@calcom/lib/logger";
import { EventTypeTranslationRepository } from "@calcom/lib/server/repository/eventTypeTranslation";
import { EventTypeAutoTranslatedField } from "@calcom/prisma/enums";
export const ZTranslateEventDataPayloadSchema = z.object({
@@ -1,13 +1,13 @@
import type { z } from "zod";
import { whereClauseForOrgWithSlugOrRequestedSlug } from "@calcom/ee/organizations/lib/orgDomains";
import { getParsedTeam } from "@calcom/features/ee/teams/lib/getParsedTeam";
import { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
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";
import { getParsedTeam } from "@calcom/lib/server/repository/teamUtils";
import { withSelectedCalendars } from "@calcom/lib/server/withSelectedCalendars";
import type { PrismaClient } from "@calcom/prisma";
import { availabilityUserSelect } from "@calcom/prisma";
@@ -123,7 +123,7 @@ const userSelect = {
} satisfies Prisma.UserSelect;
export class UserRepository {
constructor(private prismaClient: PrismaClient) { }
constructor(private prismaClient: PrismaClient) {}
async findTeamsByUserId({ userId }: { userId: UserType["id"] }) {
const teamMemberships = await this.prismaClient.membership.findMany({
@@ -236,35 +236,35 @@ export class UserRepository {
// Lookup in profiles because that's where the organization usernames exist
const profiles = orgSlug
? (
await ProfileRepository.findManyByOrgSlugOrRequestedSlug({
orgSlug: orgSlug,
usernames: usernameList,
})
).map((profile) => ({
...profile,
organization: getParsedTeam(profile.organization),
}))
await ProfileRepository.findManyByOrgSlugOrRequestedSlug({
orgSlug: orgSlug,
usernames: usernameList,
})
).map((profile) => ({
...profile,
organization: getParsedTeam(profile.organization),
}))
: null;
const where =
profiles && profiles.length > 0
? {
// Get UserIds from profiles
id: {
in: profiles.map((profile) => profile.user.id),
},
}
// Get UserIds from profiles
id: {
in: profiles.map((profile) => profile.user.id),
},
}
: {
username: {
in: usernameList,
},
...(orgSlug
? {
organization: whereClauseForOrgWithSlugOrRequestedSlug(orgSlug),
}
: {
organization: null,
}),
};
username: {
in: usernameList,
},
...(orgSlug
? {
organization: whereClauseForOrgWithSlugOrRequestedSlug(orgSlug),
}
: {
organization: null,
}),
};
return { where, profiles };
}
@@ -681,27 +681,27 @@ export class UserRepository {
async enrichEntityWithProfile<
T extends
| {
profile: {
id: number;
username: string | null;
organizationId: number | null;
organization?: {
id: number;
name: string;
calVideoLogo?: string | null;
bannerUrl: string | null;
slug: string | null;
metadata: Prisma.JsonValue;
};
};
}
| {
user: {
username: string | null;
id: number;
};
}
| {
profile: {
id: number;
username: string | null;
organizationId: number | null;
organization?: {
id: number;
name: string;
calVideoLogo?: string | null;
bannerUrl: string | null;
slug: string | null;
metadata: Prisma.JsonValue;
};
};
}
| {
user: {
username: string | null;
id: number;
};
}
>(entity: T) {
if ("profile" in entity) {
const { profile, ...entityWithoutProfile } = entity;
@@ -714,11 +714,11 @@ export class UserRepository {
...profileWithoutOrganization,
...(parsedOrg
? {
organization: parsedOrg,
}
organization: parsedOrg,
}
: {
organization: null,
}),
organization: null,
}),
},
};
return ret;
@@ -754,10 +754,10 @@ export class UserRepository {
data: {
movedToProfile: data.movedToProfileId
? {
connect: {
id: data.movedToProfileId,
},
}
connect: {
id: data.movedToProfileId,
},
}
: undefined,
},
});
@@ -803,15 +803,15 @@ export class UserRepository {
locked,
...(organizationIdValue
? {
organizationId: organizationIdValue,
profiles: {
create: {
username,
organizationId: organizationIdValue,
uid: ProfileRepository.generateProfileUid(),
organizationId: organizationIdValue,
profiles: {
create: {
username,
organizationId: organizationIdValue,
uid: ProfileRepository.generateProfileUid(),
},
},
},
}
}
: {}),
...rest,
},
@@ -1014,19 +1014,19 @@ export class UserRepository {
};
}
async findUnlockedUserForSession({ userId }: { userId: number }) {
const user = await this.prismaClient.user.findUnique({
where: {
id: userId,
// Locked users can't login
locked: false,
},
select: {
id: true,
uuid: true,
username: true,
name: true,
email: true,
async findUnlockedUserForSession({ userId }: { userId: number }) {
const user = await this.prismaClient.user.findUnique({
where: {
id: userId,
// Locked users can't login
locked: false,
},
select: {
id: true,
uuid: true,
username: true,
name: true,
email: true,
emailVerified: true,
bio: true,
avatarUrl: true,
@@ -8,7 +8,7 @@ import type {
WatchlistEntry,
FindAllEntriesInput,
WatchlistAuditEntry,
} from "./watchlist.interface";
} from "./IWatchlistRepository";
export class WatchlistRepository implements IWatchlistRepository {
constructor(private readonly prismaClient: PrismaClient) {}
@@ -1,6 +1,6 @@
import type { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import type { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import logger from "@calcom/lib/logger";
import type { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import type { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import { BookingReportStatus } from "@calcom/prisma/enums";
import { WatchlistErrors } from "../errors/WatchlistErrors";
@@ -1,7 +1,7 @@
import type { ListBookingReportsFilters } from "@calcom/features/bookingReport/repositories/IBookingReportRepository";
import type { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import type { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import type { ListBookingReportsFilters } from "@calcom/lib/server/repository/bookingReport.interface";
import type { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import type { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import type { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import type { PrismaClient } from "@calcom/prisma";
import type { WatchlistType, WatchlistSource } from "@calcom/prisma/enums";
@@ -1,7 +1,7 @@
import type { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import type { PermissionString } from "@calcom/features/pbac/domain/types/permission-registry";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import type { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import type { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import type { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import { MembershipRole } from "@calcom/prisma/enums";
import { WatchlistErrors } from "../errors/WatchlistErrors";
@@ -60,7 +60,9 @@ export class OrganizationWatchlistOperationsService extends WatchlistOperationsS
});
if (!hasPermission) {
throw WatchlistErrors.permissionDenied(`You are not authorized to ${permission.split(".")[1]} watchlist entries`);
throw WatchlistErrors.permissionDenied(
`You are not authorized to ${permission.split(".")[1]} watchlist entries`
);
}
}
@@ -1,6 +1,6 @@
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import type { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import type { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import type { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import { MembershipRole, WatchlistType, WatchlistSource } from "@calcom/prisma/enums";
import { WatchlistErrors } from "../errors/WatchlistErrors";
@@ -1,8 +1,8 @@
import type { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import type { WatchlistEntry } from "@calcom/features/watchlist/lib/repository/IWatchlistRepository";
import type { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import { domainRegex, emailRegex } from "@calcom/lib/emailSchema";
import logger from "@calcom/lib/logger";
import type { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import type { WatchlistEntry } from "@calcom/lib/server/repository/watchlist.interface";
import type { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import { WatchlistAction, WatchlistType } from "@calcom/prisma/enums";
import { WatchlistErrors } from "../errors/WatchlistErrors";
+1 -1
View File
@@ -5,7 +5,7 @@ export { ScheduleRepository as PrismaScheduleRepository } from "@calcom/features
export { BookingRepository as PrismaBookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
export { EventTypeRepository as PrismaEventTypeRepository } from "@calcom/features/eventtypes/repositories/eventTypeRepository";
export { RoutingFormResponseRepository as PrismaRoutingFormResponseRepository } from "@calcom/lib/server/repository/formResponse";
export { PrismaSelectedSlotRepository } from "@calcom/lib/server/repository/PrismaSelectedSlotRepository";
export { PrismaSelectedSlotRepository } from "@calcom/features/selectedSlots/repositories/PrismaSelectedSlotRepository";
export { TeamRepository as PrismaTeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
export { UserRepository as PrismaUserRepository } from "@calcom/features/users/repositories/UserRepository";
export { FeaturesRepository as PrismaFeaturesRepository } from "@calcom/features/flags/features.repository";
@@ -1,4 +1,4 @@
import { PrismaApiKeyRepository } from "@calcom/lib/server/repository/PrismaApiKeyRepository";
import { PrismaApiKeyRepository } from "@calcom/features/ee/api-keys/repositories/PrismaApiKeyRepository";
import type { PrismaClient } from "@calcom/prisma";
import type { TrpcSessionUser } from "../../../types";
@@ -1,16 +1,16 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
import { BookingAccessService } from "@calcom/features/bookings/services/BookingAccessService";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { BookingStatus, BookingReportReason } from "@calcom/prisma/enums";
import { TRPCError } from "@trpc/server";
import { reportBookingHandler } from "./reportBooking.handler";
vi.mock("@calcom/lib/server/repository/bookingReport");
vi.mock("@calcom/features/bookingReport/repositories/PrismaBookingReportRepository");
vi.mock("@calcom/features/bookings/lib/handleCancelBooking");
vi.mock("@calcom/features/bookings/repositories/BookingRepository");
vi.mock("@calcom/features/bookings/services/BookingAccessService");
@@ -1,8 +1,8 @@
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
import { BookingAccessService } from "@calcom/features/bookings/services/BookingAccessService";
import logger from "@calcom/lib/logger";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import prisma from "@calcom/prisma";
import { BookingStatus } from "@calcom/prisma/enums";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
@@ -6,7 +6,7 @@ import { WatchlistType, WatchlistAction } from "@calcom/prisma/enums";
import { deleteWatchlistEntryHandler } from "./deleteWatchlistEntry.handler";
vi.mock("@calcom/features/di/watchlist/containers/watchlist");
vi.mock("@calcom/lib/server/repository/watchlist.repository");
vi.mock("@calcom/features/watchlist/lib/repository/WatchlistRepository");
describe("deleteWatchlistEntryHandler", () => {
const mockUser = {
@@ -40,7 +40,9 @@ describe("deleteWatchlistEntryHandler", () => {
const { getOrganizationWatchlistOperationsService } = await import(
"@calcom/features/di/watchlist/containers/watchlist"
);
const { WatchlistRepository } = await import("@calcom/lib/server/repository/watchlist.repository");
const { WatchlistRepository } = await import(
"@calcom/features/watchlist/lib/repository/WatchlistRepository"
);
vi.mocked(getOrganizationWatchlistOperationsService).mockReturnValue(mockService as never);
vi.mocked(WatchlistRepository).mockImplementation(() => mockWatchlistRepo as never);
@@ -1,6 +1,6 @@
import { getOrganizationWatchlistOperationsService } from "@calcom/features/di/watchlist/containers/watchlist";
import { WatchlistError, WatchlistErrorCode } from "@calcom/features/watchlist/lib/errors/WatchlistErrors";
import { WatchlistRepository } from "@calcom/lib/server/repository/watchlist.repository";
import { WatchlistRepository } from "@calcom/features/watchlist/lib/repository/WatchlistRepository";
import { prisma } from "@calcom/prisma";
import { TRPCError } from "@trpc/server";
@@ -1,13 +1,13 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { MembershipRole, BookingReportReason } from "@calcom/prisma/enums";
import { dismissBookingReportHandler } from "./dismissBookingReport.handler";
vi.mock("@calcom/features/pbac/services/permission-check.service");
vi.mock("@calcom/lib/server/repository/bookingReport");
vi.mock("@calcom/features/bookingReport/repositories/PrismaBookingReportRepository");
describe("dismissBookingReportHandler", () => {
const mockUser = {
@@ -1,5 +1,5 @@
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -1,5 +1,6 @@
import { LicenseKeySingleton } from "@calcom/ee/common/server/LicenseKeyService";
import { OrganizationOnboardingFactory } from "@calcom/ee/organizations/lib/service/onboarding/OrganizationOnboardingFactory";
import { DeploymentRepository } from "@calcom/features/ee/deployment/repositories/DeploymentRepository";
import {
assertCanCreateOrg,
findUserToBeOrgOwner,
@@ -8,7 +9,6 @@ import { OrganizationOnboardingRepository } from "@calcom/features/organizations
import { IS_SELF_HOSTED } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { DeploymentRepository } from "@calcom/lib/server/repository/deployment";
import { prisma } from "@calcom/prisma";
import { UserPermissionRole } from "@calcom/prisma/enums";
@@ -1,13 +1,13 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { MembershipRole, BookingReportReason, BookingReportStatus } from "@calcom/prisma/enums";
import { listBookingReportsHandler } from "./listBookingReports.handler";
vi.mock("@calcom/features/pbac/services/permission-check.service");
vi.mock("@calcom/lib/server/repository/bookingReport");
vi.mock("@calcom/features/bookingReport/repositories/PrismaBookingReportRepository");
describe("listBookingReportsHandler (Organization)", () => {
const mockUser = {
@@ -1,5 +1,5 @@
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -1,5 +1,5 @@
import { PrismaBookingReportRepository } from "@calcom/features/bookingReport/repositories/PrismaBookingReportRepository";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { PrismaBookingReportRepository } from "@calcom/lib/server/repository/bookingReport";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -1,9 +1,9 @@
import type { NextApiRequest } from "next";
import { EventTypeRepository } from "@calcom/features/eventtypes/repositories/eventTypeRepository";
import { PrismaSelectedSlotRepository } from "@calcom/features/selectedSlots/repositories/PrismaSelectedSlotRepository";
import { HttpError } from "@calcom/lib/http-error";
import { getPastTimeAndMinimumBookingNoticeBoundsStatus } from "@calcom/lib/isOutOfBounds";
import { PrismaSelectedSlotRepository } from "@calcom/lib/server/repository/PrismaSelectedSlotRepository";
import type { PrismaClient } from "@calcom/prisma";
import type { TIsAvailableInputSchema, TIsAvailableOutputSchema } from "./isAvailable.schema";
@@ -12,7 +12,7 @@ const dynamicImportHandler = async () => await import("./reserveSlot.handler");
// The repository instance method is used to check for an existing reservation by someone else.
// To keep this unit test isolated from the database layer, we stub this to always resolve falsey.
vi.mock("@calcom/lib/server/repository/PrismaSelectedSlotRepository", () => ({
vi.mock("@calcom/features/selectedSlots/repositories/PrismaSelectedSlotRepository", () => ({
PrismaSelectedSlotRepository: vi.fn().mockImplementation(() => ({
findReservedByOthers: vi.fn().mockResolvedValue(null),
})),
@@ -3,9 +3,9 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { v4 as uuid } from "uuid";
import dayjs from "@calcom/dayjs";
import { PrismaSelectedSlotRepository } from "@calcom/features/selectedSlots/repositories/PrismaSelectedSlotRepository";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
import { PrismaSelectedSlotRepository } from "@calcom/lib/server/repository/PrismaSelectedSlotRepository";
import type { PrismaClient } from "@calcom/prisma";
import { BookingStatus } from "@calcom/prisma/enums";
@@ -29,6 +29,7 @@ import type { IRedisService } from "@calcom/features/redis/IRedisService";
import { buildDateRanges } from "@calcom/features/schedules/lib/date-ranges";
import getSlots from "@calcom/features/schedules/lib/slots";
import type { ScheduleRepository } from "@calcom/features/schedules/repositories/ScheduleRepository";
import type { ISelectedSlotRepository } from "@calcom/features/selectedSlots/repositories/ISelectedSlotRepository";
import type { NoSlotsNotificationService } from "@calcom/features/slots/handleNotificationWhenNoSlots";
import type { UserRepository } from "@calcom/features/users/repositories/UserRepository";
import { withSelectedCalendars } from "@calcom/features/users/repositories/UserRepository";
@@ -50,7 +51,6 @@ import {
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { withReporting } from "@calcom/lib/sentryWrapper";
import type { ISelectedSlotRepository } from "@calcom/lib/server/repository/ISelectedSlotRepository";
import type { RoutingFormResponseRepository } from "@calcom/lib/server/repository/formResponse";
import { SchedulingType, PeriodType } from "@calcom/prisma/enums";
import type { EventBusyDate, EventBusyDetails } from "@calcom/types/Calendar";
@@ -7,7 +7,7 @@ import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowE
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { getTranslation } from "@calcom/lib/server/i18n";
import { isOrganisationOwner } from "@calcom/lib/server/queries/organisations";
import { isOrganisationOwner } from "@calcom/features/pbac/utils/isOrganisationAdmin";
import prisma from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
import type { CreationSource } from "@calcom/prisma/enums";
@@ -34,7 +34,7 @@ vi.mock("@calcom/prisma", () => {
};
});
vi.mock("@calcom/lib/server/queries/organisations", () => {
vi.mock("@calcom/features/pbac/utils/isOrganisationAdmin", () => {
return {
isOrganisationAdmin: vi.fn(),
isOrganisationOwner: vi.fn(),
@@ -4,6 +4,7 @@ import type { TFunction } from "i18next";
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
import { sendTeamInviteEmail } from "@calcom/emails/organization-email-service";
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
import { getParsedTeam } from "@calcom/features/ee/teams/lib/getParsedTeam";
import { updateNewTeamMemberEventTypes } from "@calcom/features/ee/teams/lib/queries";
import { OnboardingPathService } from "@calcom/features/onboarding/lib/onboarding-path.service";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
@@ -15,7 +16,6 @@ import { ENABLE_PROFILE_SWITCHER, WEBAPP_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { getTranslation } from "@calcom/lib/server/i18n";
import { getParsedTeam } from "@calcom/lib/server/repository/teamUtils";
import slugify from "@calcom/lib/slugify";
import { prisma } from "@calcom/prisma";
import type { Membership, OrganizationSettings, Team } from "@calcom/prisma/client";
@@ -8,6 +8,7 @@ import { WorkflowReminderRepository } from "@calcom/features/ee/workflows/lib/re
import { scheduleWorkflowNotifications } from "@calcom/features/ee/workflows/lib/scheduleWorkflowNotifications";
import { verifyEmailSender } from "@calcom/features/ee/workflows/lib/verifyEmailSender";
import { WorkflowRepository } from "@calcom/features/ee/workflows/repositories/WorkflowRepository";
import { WorkflowStepRepository } from "@calcom/features/ee/workflows/repositories/WorkflowStepRepository";
import { EventTypeRepository } from "@calcom/features/eventtypes/repositories/eventTypeRepository";
import tasker from "@calcom/features/tasker";
import { addPermissionsToWorkflow } from "@calcom/features/workflows/repositories/WorkflowPermissionsRepository";
@@ -15,7 +16,6 @@ import { IS_SELF_HOSTED, SCANNING_WORKFLOW_STEPS } from "@calcom/lib/constants";
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
import logger from "@calcom/lib/logger";
import { WorkflowRelationsRepository } from "@calcom/lib/server/repository/workflowRelations";
import { WorkflowStepRepository } from "@calcom/lib/server/repository/workflowStep";
import { prisma, type PrismaClient } from "@calcom/prisma";
import { WorkflowActions, WorkflowTemplates } from "@calcom/prisma/enums";
import { PhoneNumberSubscriptionStatus } from "@calcom/prisma/enums";