fix: circular dependencies (#20378)

* fix: circular dependencies

* fix: type err
This commit is contained in:
Udit Takkar
2025-03-26 12:42:40 -04:00
committed by GitHub
parent d04f10e7d1
commit 596e9b4e5a
20 changed files with 158 additions and 146 deletions
@@ -1,11 +1,5 @@
import { test } from "../../lib/fixtures";
export type TApp = {
slug: string;
type: string;
organizerInputPlaceholder?: string;
label: string;
};
import type { TApp } from "./types";
const APP: TApp = {
slug: "around",
@@ -0,0 +1,6 @@
export type TApp = {
slug: string;
type: string;
organizerInputPlaceholder?: string;
label: string;
};
+2 -1
View File
@@ -3,7 +3,8 @@ import { expect } from "@playwright/test";
import dayjs from "@calcom/dayjs";
import { test } from "./lib/fixtures";
import { localize, submitAndWaitForResponse } from "./lib/testUtils";
import { localize } from "./lib/localize";
import { submitAndWaitForResponse } from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
+1 -1
View File
@@ -1,6 +1,6 @@
import { expect, type Page } from "@playwright/test";
import type { TApp } from "../apps/conferencing/conferencingApps.e2e";
import type { TApp } from "../apps/conferencing/types";
import {
bookTimeSlot,
gotoBookingPage,
+1 -1
View File
@@ -1,6 +1,6 @@
import { expect, type Page } from "@playwright/test";
import { localize } from "../lib/testUtils";
import { localize } from "../lib/localize";
export function createEventTypeFixture(page: Page) {
return {
@@ -2,7 +2,8 @@ import { expect, type Page } from "@playwright/test";
import type { MembershipRole } from "@calcom/prisma/enums";
import { localize, submitAndWaitForResponse } from "../lib/testUtils";
import { localize } from "../lib/localize";
import { submitAndWaitForResponse } from "../lib/testUtils";
import type { createUsersFixture } from "./users";
export const scheduleSuccessfullyText = "This meeting is scheduled";
+1 -1
View File
@@ -4,7 +4,7 @@ import { expect, type Page } from "@playwright/test";
import prisma from "@calcom/prisma";
import { WorkflowTriggerEvents } from "@calcom/prisma/enums";
import { localize } from "../lib/testUtils";
import { localize } from "../lib/localize";
type CreateWorkflowProps = {
name?: string;
+11
View File
@@ -0,0 +1,11 @@
import { loadJSON } from "./loadJSON";
// Provide an standalone localize utility not managed by next-i18n
export async function localize(locale: string) {
const localeModule = `../../public/static/locales/${locale}/common.json`;
const localeMap = loadJSON(localeModule);
return (message: string) => {
if (message in localeMap) return localeMap[message];
throw "No locale found for the given entry message";
};
}
-11
View File
@@ -14,7 +14,6 @@ import { BookingStatus, SchedulingType } from "@calcom/prisma/enums";
import type { createEmailsFixture } from "../fixtures/emails";
import type { Fixtures } from "./fixtures";
import { loadJSON } from "./loadJSON";
type Request = IncomingMessage & { body?: unknown };
type RequestHandlerOptions = { req: Request; res: ServerResponse };
@@ -178,16 +177,6 @@ export async function expectSlotNotAllowedToBook(page: Page) {
await expect(page.locator("[data-testid=slot-not-allowed-to-book]")).toBeVisible();
}
// Provide an standalone localize utility not managed by next-i18n
export async function localize(locale: string) {
const localeModule = `../../public/static/locales/${locale}/common.json`;
const localeMap = loadJSON(localeModule);
return (message: string) => {
if (message in localeMap) return localeMap[message];
throw "No locale found for the given entry message";
};
}
export const createNewEventType = async (page: Page, args: { eventTitle: string }) => {
await page.click("[data-testid=new-event-type]");
const eventTitle = args.eventTitle;
+1 -1
View File
@@ -2,7 +2,7 @@ import { expect } from "@playwright/test";
import { login } from "./fixtures/users";
import { test } from "./lib/fixtures";
import { localize } from "./lib/testUtils";
import { localize } from "./lib/localize";
test.describe.configure({ mode: "parallel" });
@@ -2,9 +2,9 @@ import type { Locator, Page } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./lib/fixtures";
import { localize } from "./lib/localize";
import {
bookTimeSlot,
localize,
submitAndWaitForResponse,
selectFirstAvailableTimeSlotNextMonth,
setupManagedEvent,
+2 -1
View File
@@ -8,7 +8,8 @@ import prisma from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
import { test } from "./lib/fixtures";
import { submitAndWaitForResponse, localize } from "./lib/testUtils";
import { localize } from "./lib/localize";
import { submitAndWaitForResponse } from "./lib/testUtils";
test.describe.configure({ mode: "parallel" });
test.afterEach(async ({ users }) => {
+2 -1
View File
@@ -6,7 +6,8 @@ import { APP_NAME, IS_PREMIUM_USERNAME_ENABLED, IS_MAILHOG_ENABLED } from "@calc
import prisma from "@calcom/prisma";
import { test } from "./lib/fixtures";
import { getEmailsReceivedByUser, localize } from "./lib/testUtils";
import { localize } from "./lib/localize";
import { getEmailsReceivedByUser } from "./lib/testUtils";
import { expectInvitationEmailToBeReceived } from "./team/expects";
test.describe.configure({ mode: "parallel" });
@@ -5,7 +5,8 @@ import { prisma } from "@calcom/prisma";
import { MembershipRole, SchedulingType } from "@calcom/prisma/enums";
import { test } from "../lib/fixtures";
import { getInviteLink, localize } from "../lib/testUtils";
import { localize } from "../lib/localize";
import { getInviteLink } from "../lib/testUtils";
import { expectInvitationEmailToBeReceived } from "./expects";
test.describe.configure({ mode: "parallel" });
@@ -0,0 +1,104 @@
import { workflowSelect } from "@calcom/features/ee/workflows/lib/getAllWorkflows";
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
export async function getBookingToDelete(id: number | undefined, uid: string | undefined) {
return await prisma.booking.findUniqueOrThrow({
where: {
id,
uid,
},
select: {
...bookingMinimalSelect,
recurringEventId: true,
userId: true,
user: {
select: {
id: true,
username: true,
credentials: { select: credentialForCalendarServiceSelect }, // Not leaking at the moment, be careful with
email: true,
timeZone: true,
timeFormat: true,
name: true,
destinationCalendar: true,
},
},
location: true,
references: {
select: {
uid: true,
type: true,
externalCalendarId: true,
credentialId: true,
thirdPartyRecurringEventId: true,
delegationCredentialId: true,
},
},
payment: true,
paid: true,
eventType: {
select: {
slug: true,
owner: {
select: {
id: true,
hideBranding: true,
},
},
team: {
select: {
id: true,
name: true,
parentId: true,
},
},
parentId: true,
parent: {
select: {
teamId: true,
},
},
userId: true,
recurringEvent: true,
title: true,
eventName: true,
description: true,
requiresConfirmation: true,
price: true,
currency: true,
length: true,
seatsPerTimeSlot: true,
bookingFields: true,
seatsShowAttendees: true,
metadata: true,
schedulingType: true,
hosts: {
select: {
user: true,
},
},
workflows: {
select: {
workflow: {
select: workflowSelect,
},
},
},
},
},
uid: true,
id: true,
eventTypeId: true,
destinationCalendar: true,
smsReminderNumber: true,
workflowReminders: true,
seatsReferences: true,
responses: true,
iCalUID: true,
iCalSequence: true,
},
});
}
export type BookingToDelete = Awaited<ReturnType<typeof getBookingToDelete>>;
@@ -6,7 +6,6 @@ import { DailyLocationType } from "@calcom/app-store/locations";
import dayjs from "@calcom/dayjs";
import { sendCancelledEmailsAndSMS } from "@calcom/emails";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import { workflowSelect } from "@calcom/features/ee/workflows/lib/getAllWorkflows";
import { sendCancelledReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler";
import type { GetSubscriberOptions } from "@calcom/features/webhooks/lib/getWebhooks";
import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks";
@@ -25,133 +24,22 @@ import { safeStringify } from "@calcom/lib/safeStringify";
import { getTranslation } from "@calcom/lib/server/i18n";
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
import prisma from "@calcom/prisma";
import type { WebhookTriggerEvents } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import { bookingMetadataSchema, EventTypeMetaDataSchema, bookingCancelInput } from "@calcom/prisma/zod-utils";
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util";
import type { CalendarEvent } from "@calcom/types/Calendar";
import { getAllCredentials } from "./getAllCredentialsForUsersOnEvent/getAllCredentials";
import { getBookingToDelete } from "./getBookingToDelete";
import type { CustomRequest, AppRouterRequest } from "./handleCancelBooking/types";
import { handleInternalNote } from "./handleInternalNote";
import cancelAttendeeSeat from "./handleSeats/cancel/cancelAttendeeSeat";
const log = logger.getSubLogger({ prefix: ["handleCancelBooking"] });
async function getBookingToDelete(id: number | undefined, uid: string | undefined) {
return await prisma.booking.findUniqueOrThrow({
where: {
id,
uid,
},
select: {
...bookingMinimalSelect,
recurringEventId: true,
userId: true,
user: {
select: {
id: true,
username: true,
credentials: { select: credentialForCalendarServiceSelect }, // Not leaking at the moment, be careful with
email: true,
timeZone: true,
timeFormat: true,
name: true,
destinationCalendar: true,
},
},
location: true,
references: {
select: {
uid: true,
type: true,
externalCalendarId: true,
credentialId: true,
thirdPartyRecurringEventId: true,
delegationCredentialId: true,
},
},
payment: true,
paid: true,
eventType: {
select: {
slug: true,
owner: {
select: {
id: true,
hideBranding: true,
},
},
team: {
select: {
id: true,
name: true,
parentId: true,
},
},
parentId: true,
parent: {
select: {
teamId: true,
},
},
userId: true,
recurringEvent: true,
title: true,
eventName: true,
description: true,
requiresConfirmation: true,
price: true,
currency: true,
length: true,
seatsPerTimeSlot: true,
bookingFields: true,
seatsShowAttendees: true,
metadata: true,
schedulingType: true,
hosts: {
select: {
user: true,
},
},
workflows: {
select: {
workflow: {
select: workflowSelect,
},
},
},
},
},
uid: true,
id: true,
eventTypeId: true,
destinationCalendar: true,
smsReminderNumber: true,
workflowReminders: true,
seatsReferences: true,
responses: true,
iCalUID: true,
iCalSequence: true,
},
});
}
export type BookingToDelete = Awaited<ReturnType<typeof getBookingToDelete>>;
export type AppRouterRequest = { appDirRequestBody: unknown };
export type CustomRequest = (NextApiRequest | AppRouterRequest) & {
userId?: number;
bookingToDelete?: BookingToDelete;
platformClientId?: string;
platformRescheduleUrl?: string;
platformCancelUrl?: string;
platformBookingUrl?: string;
arePlatformEmailsEnabled?: boolean;
};
export type HandleCancelBookingResponse = {
success: boolean;
message: string;
@@ -0,0 +1,14 @@
import type { NextApiRequest } from "next";
import type { BookingToDelete } from "../getBookingToDelete";
export type AppRouterRequest = { appDirRequestBody: unknown };
export type CustomRequest = (NextApiRequest | AppRouterRequest) & {
userId?: number;
bookingToDelete?: BookingToDelete;
platformClientId?: string;
platformRescheduleUrl?: string;
platformCancelUrl?: string;
platformBookingUrl?: string;
arePlatformEmailsEnabled?: boolean;
};
@@ -1,7 +1,7 @@
import { HttpError } from "@calcom/lib/http-error";
import prisma from "@calcom/prisma";
import { type BookingToDelete } from "./handleCancelBooking";
import type { BookingToDelete } from "./getBookingToDelete";
type InternalNote = {
id: number;
@@ -18,7 +18,7 @@ import { bookingCancelAttendeeSeatSchema } from "@calcom/prisma/zod-utils";
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
import type { CalendarEvent } from "@calcom/types/Calendar";
import type { AppRouterRequest, CustomRequest } from "../../handleCancelBooking";
import type { AppRouterRequest, CustomRequest } from "../../handleCancelBooking/types";
async function cancelAttendeeSeat(
req: CustomRequest,
@@ -1,10 +1,11 @@
import { DataTableSelectionBar } from "@calcom/features/data-table";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import type { RouterOutputs } from "@calcom/trpc/react";
import { Dialog, DialogTrigger, ConfirmationDialogContent } from "@calcom/ui/components/dialog";
import { showToast } from "@calcom/ui/components/toast";
import type { User } from "./MemberList";
export type User = RouterOutputs["viewer"]["teams"]["listMembers"]["members"][number];
interface Props {
users: User[];