Skip to content

Scheduling infrastructure for absolutely everyone.

perf: fix circular dependencies (#20121)

Udit Takkar55a97b71c812
diff --git a/packages/app-store/basecamp3/lib/CalendarService.ts b/packages/app-store/basecamp3/lib/CalendarService.ts
index 46531a6dee8..e251ae33db4 100644
--- a/packages/app-store/basecamp3/lib/CalendarService.ts
+++ b/packages/app-store/basecamp3/lib/CalendarService.ts
@@ -11,6 +11,7 @@ import type { CredentialPayload } from "@calcom/types/Credential";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import { refreshAccessToken as getNewTokens } from "./helpers";
+import type { BasecampToken } from "./types";
function hasFileExtension(url: string): boolean {
// Get the last portion of the URL (after the last '/')
@@ -28,23 +29,6 @@ function getFileExtension(url: string): string {
return fileName.substring(fileName.lastIndexOf(".") + 1);
}
-export type BasecampToken = {
- projectId: number;
- expires_at: number;
- expires_in: number;
- scheduleId: number;
- access_token: string;
- refresh_token: string;
- account: {
- id: number;
- href: string;
- name: string;
- hidden: boolean;
- product: string;
- app_href: string;
- };
-};
-
export default class BasecampCalendarService implements Calendar {
private credentials: Record<string, string> = {};
private auth: Promise<{ configureToken: () => Promise<void> }>;
diff --git a/packages/app-store/basecamp3/lib/helpers.ts b/packages/app-store/basecamp3/lib/helpers.ts
index 521a04e4a4e..8acb872937e 100644
--- a/packages/app-store/basecamp3/lib/helpers.ts
+++ b/packages/app-store/basecamp3/lib/helpers.ts
@@ -2,8 +2,8 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
import { prisma } from "@calcom/prisma";
import type { CredentialPayload } from "@calcom/types/Credential";
-import type { BasecampToken } from "./CalendarService";
import { getBasecampKeys } from "./getBasecampKeys";
+import type { BasecampToken } from "./types";
export const refreshAccessToken = async (credential: CredentialPayload) => {
const { client_id: clientId, client_secret: clientSecret, user_agent: userAgent } = await getBasecampKeys();
diff --git a/packages/app-store/basecamp3/lib/types.ts b/packages/app-store/basecamp3/lib/types.ts
new file mode 100644
index 00000000000..dfda2bfc53c
--- /dev/null
+++ b/packages/app-store/basecamp3/lib/types.ts
@@ -0,0 +1,16 @@
+export type BasecampToken = {
+ projectId: number;
+ expires_at: number;
+ expires_in: number;
+ scheduleId: number;
+ access_token: string;
+ refresh_token: string;
+ account: {
+ id: number;
+ href: string;
+ name: string;
+ hidden: boolean;
+ product: string;
+ app_href: string;
+ };
+};
diff --git a/packages/app-store/basecamp3/trpc/projectMutation.handler.ts b/packages/app-store/basecamp3/trpc/projectMutation.handler.ts
index 24c22d9e254..ece4c5f15a9 100644
--- a/packages/app-store/basecamp3/trpc/projectMutation.handler.ts
+++ b/packages/app-store/basecamp3/trpc/projectMutation.handler.ts
@@ -5,8 +5,8 @@ import type { TrpcSessionUser } from "@calcom/trpc/server/types";
import { TRPCError } from "@trpc/server";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
-import type { BasecampToken } from "../lib/CalendarService";
import { refreshAccessToken } from "../lib/helpers";
+import type { BasecampToken } from "../lib/types";
import type { TProjectMutationInputSchema } from "./projectMutation.schema";
interface ProjectMutationHandlerOptions {
diff --git a/packages/app-store/basecamp3/trpc/projects.handler.ts b/packages/app-store/basecamp3/trpc/projects.handler.ts
index 8db93de1384..c53f9cc3970 100644
--- a/packages/app-store/basecamp3/trpc/projects.handler.ts
+++ b/packages/app-store/basecamp3/trpc/projects.handler.ts
@@ -5,8 +5,8 @@ import type { TrpcSessionUser } from "@calcom/trpc/server/types";
import { TRPCError } from "@trpc/server";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
-import type { BasecampToken } from "../lib/CalendarService";
import { refreshAccessToken } from "../lib/helpers";
+import type { BasecampToken } from "../lib/types";
interface ProjectsHandlerOptions {
ctx: {
diff --git a/packages/app-store/routing-forms/components/RoutingNavBar.tsx b/packages/app-store/routing-forms/components/RoutingNavBar.tsx
index c1e1a891137..9137cb9dae3 100644
--- a/packages/app-store/routing-forms/components/RoutingNavBar.tsx
+++ b/packages/app-store/routing-forms/components/RoutingNavBar.tsx
@@ -6,7 +6,7 @@ import { HorizontalTabs } from "@calcom/ui/components/navigation";
import { enabledIncompleteBookingApps } from "../lib/enabledIncompleteBookingApps";
import type { getSerializableForm } from "../lib/getSerializableForm";
-import type { RoutingFormWithResponseCount } from "./SingleForm";
+import type { RoutingFormWithResponseCount } from "../types/types";
export default function RoutingNavBar({
form,
diff --git a/packages/app-store/routing-forms/components/SingleForm.tsx b/packages/app-store/routing-forms/components/SingleForm.tsx
index b8349c4d0d0..032f898dd6c 100644
--- a/packages/app-store/routing-forms/components/SingleForm.tsx
+++ b/packages/app-store/routing-forms/components/SingleForm.tsx
@@ -1,4 +1,3 @@
-import type { App_RoutingForms_Form, Team } from "@prisma/client";
import Link from "next/link";
import { useEffect, useState } from "react";
import type { UseFormReturn } from "react-hook-form";
@@ -35,7 +34,7 @@ import { getAbsoluteEventTypeRedirectUrl } from "../getEventTypeRedirectUrl";
import { RoutingPages } from "../lib/RoutingPages";
import { isFallbackRoute } from "../lib/isFallbackRoute";
import { findMatchingRoute } from "../lib/processRoute";
-import type { FormResponse, NonRouterRoute, SerializableForm } from "../types/types";
+import type { FormResponse, NonRouterRoute, RoutingFormWithResponseCount, RoutingForm } from "../types/types";
import type { NewFormDialogState } from "./FormActions";
import { FormAction, FormActionsDropdown, FormActionsProvider } from "./FormActions";
import FormInputFields from "./FormInputFields";
@@ -43,18 +42,6 @@ import { InfoLostWarningDialog } from "./InfoLostWarningDialog";
import RoutingNavBar from "./RoutingNavBar";
import { getServerSidePropsForSingleFormView } from "./getServerSidePropsSingleForm";
-type RoutingForm = SerializableForm<App_RoutingForms_Form>;
-
-export type RoutingFormWithResponseCount = RoutingForm & {
- team: {
- slug: Team["slug"];
- name: Team["name"];
- } | null;
- _count: {
- responses: number;
- };
-};
-
const Actions = ({
form,
mutation,
diff --git a/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx b/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx
index 0c9c879d7e2..c3ec97cc51c 100644
--- a/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx
@@ -17,11 +17,11 @@ import { Skeleton } from "@calcom/ui/components/skeleton";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
-import type { RoutingFormWithResponseCount } from "../../components/SingleForm";
import SingleForm, {
getServerSidePropsForSingleFormView as getServerSideProps,
} from "../../components/SingleForm";
import { FieldTypes } from "../../lib/FieldTypes";
+import type { RoutingFormWithResponseCount } from "../../types/types";
export { getServerSideProps };
type SelectOption = { label: string; id: string | null };
diff --git a/packages/app-store/routing-forms/pages/forms/[...appPages].tsx b/packages/app-store/routing-forms/pages/forms/[...appPages].tsx
index 97a9bc9053d..01fc3650822 100644
--- a/packages/app-store/routing-forms/pages/forms/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/forms/[...appPages].tsx
@@ -30,8 +30,8 @@ import type { inferSSRProps } from "@lib/types/inferSSRProps";
import type { SetNewFormDialogState, NewFormDialogState } from "../../components/FormActions";
import { FormAction, FormActionsDropdown, FormActionsProvider } from "../../components/FormActions";
-import type { RoutingFormWithResponseCount } from "../../components/SingleForm";
import { isFallbackRoute } from "../../lib/isFallbackRoute";
+import type { RoutingFormWithResponseCount } from "../../types/types";
import { getServerSideProps } from "./getServerSideProps";
function NewFormButton({ setNewFormDialogState }: { setNewFormDialogState: SetNewFormDialogState }) {
diff --git a/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx b/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx
index a11e2eb6ded..557ebc8bede 100644
--- a/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/incomplete-booking/[...appPages].tsx
@@ -19,7 +19,7 @@ import { showToast } from "@calcom/ui/components/toast";
import SingleForm, {
getServerSidePropsForSingleFormView as getServerSideProps,
} from "../../components/SingleForm";
-import type { RoutingFormWithResponseCount } from "../../components/SingleForm";
+import type { RoutingFormWithResponseCount } from "../../types/types";
function Page({ form }: { form: RoutingFormWithResponseCount }) {
const { t } = useLocale();
diff --git a/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx b/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx
index a6c8a4bbba8..4a7fed94240 100644
--- a/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/route-builder/[...appPages].tsx
@@ -27,7 +27,6 @@ import { SettingsToggle } from "@calcom/ui/components/form";
import { routingFormAppComponents } from "../../appComponents";
import DynamicAppComponent from "../../components/DynamicAppComponent";
-import type { RoutingFormWithResponseCount } from "../../components/SingleForm";
import SingleForm, {
getServerSidePropsForSingleFormView as getServerSideProps,
} from "../../components/SingleForm";
@@ -46,6 +45,7 @@ import {
isDynamicOperandField,
} from "../../lib/getQueryBuilderConfig";
import isRouter from "../../lib/isRouter";
+import type { RoutingFormWithResponseCount } from "../../types/types";
import type {
GlobalRoute,
LocalRoute,
diff --git a/packages/app-store/routing-forms/types/types.d.ts b/packages/app-store/routing-forms/types/types.d.ts
index 2e65d1520fe..a7b4791d468 100644
--- a/packages/app-store/routing-forms/types/types.d.ts
+++ b/packages/app-store/routing-forms/types/types.d.ts
@@ -102,3 +102,13 @@ export type LocalRouteWithRaqbStates = LocalRoute & {
};
export type EditFormRoute = LocalRouteWithRaqbStates | GlobalRoute;
+
+export type RoutingFormWithResponseCount = RoutingForm & {
+ team: {
+ slug: Team["slug"];
+ name: Team["name"];
+ } | null;
+ _count: {
+ responses: number;
+ };
+};
diff --git a/packages/app-store/zapier/components/AppSettingsInterface.tsx b/packages/app-store/zapier/components/AppSettingsInterface.tsx
index 0cd2877d30c..c2aa341375d 100644
--- a/packages/app-store/zapier/components/AppSettingsInterface.tsx
+++ b/packages/app-store/zapier/components/AppSettingsInterface.tsx
@@ -1,13 +1,7 @@
import { useLocale } from "@calcom/lib/hooks/useLocale";
import TemplateCard from "./TemplateCard";
-
-export type Template = {
- icon: string;
- app: string;
- text: string;
- link: string;
-};
+import type { Template } from "./types";
const templates: Template[] = [
{
diff --git a/packages/app-store/zapier/components/TemplateCard.tsx b/packages/app-store/zapier/components/TemplateCard.tsx
index 3f6d1678717..636a4e22a53 100644
--- a/packages/app-store/zapier/components/TemplateCard.tsx
+++ b/packages/app-store/zapier/components/TemplateCard.tsx
@@ -1,6 +1,6 @@
import { Button } from "@calcom/ui/components/button";
-import type { Template } from "./AppSettingsInterface";
+import type { Template } from "./types";
export default function TemplateCard({ template }: { template: Template }) {
return (
diff --git a/packages/app-store/zapier/components/types.ts b/packages/app-store/zapier/components/types.ts
new file mode 100644
index 00000000000..14da8329d0a
--- /dev/null
+++ b/packages/app-store/zapier/components/types.ts
@@ -0,0 +1,6 @@
+export type Template = {
+ icon: string;
+ app: string;
+ text: string;
+ link: string;
+};
diff --git a/packages/trpc/server/routers/viewer/slots/_router.tsx b/packages/trpc/server/routers/viewer/slots/_router.tsx
index df8c6f28c6a..a499517329b 100644
--- a/packages/trpc/server/routers/viewer/slots/_router.tsx
+++ b/packages/trpc/server/routers/viewer/slots/_router.tsx
@@ -2,10 +2,10 @@ import type { NextApiRequest, NextApiResponse } from "next";
import publicProcedure from "../../../procedures/publicProcedure";
import { router } from "../../../trpc";
-import { ZGetScheduleInputSchema } from "./getSchedule.schema";
import { ZIsAvailableInputSchema, ZIsAvailableOutputSchema } from "./isAvailable.schema";
import { ZRemoveSelectedSlotInputSchema } from "./removeSelectedSlot.schema";
import { ZReserveSlotInputSchema } from "./reserveSlot.schema";
+import { ZGetScheduleInputSchema } from "./types";
type SlotsRouterHandlerCache = {
getSchedule?: typeof import("./getSchedule.handler").getScheduleHandler;
diff --git a/packages/trpc/server/routers/viewer/slots/getSchedule.schema.ts b/packages/trpc/server/routers/viewer/slots/getSchedule.schema.ts
index 89ccc014d77..f5929c30f1d 100644
--- a/packages/trpc/server/routers/viewer/slots/getSchedule.schema.ts
+++ b/packages/trpc/server/routers/viewer/slots/getSchedule.schema.ts
@@ -1,7 +1,3 @@
-import type { z } from "zod";
+import type { TGetScheduleInputSchema as TGetScheduleInput } from "./types";
-import { getScheduleSchema } from "./types";
-
-export const ZGetScheduleInputSchema = getScheduleSchema;
-
-export type TGetScheduleInputSchema = z.infer<typeof ZGetScheduleInputSchema>;
+export type TGetScheduleInputSchema = TGetScheduleInput;
diff --git a/packages/trpc/server/routers/viewer/slots/types.ts b/packages/trpc/server/routers/viewer/slots/types.ts
index 27d4d9f6fff..f660b09a49b 100644
--- a/packages/trpc/server/routers/viewer/slots/types.ts
+++ b/packages/trpc/server/routers/viewer/slots/types.ts
@@ -1,8 +1,6 @@
import type { IncomingMessage } from "http";
import { z } from "zod";
-import type { TGetScheduleInputSchema } from "./getSchedule.schema";
-
export const getScheduleSchema = z
.object({
// startTime ISOString
@@ -82,6 +80,9 @@ export interface ContextForGetSchedule extends Record<string, unknown> {
req?: (IncomingMessage & { cookies: Partial<{ [key: string]: string }> }) | undefined;
}
+export type TGetScheduleInputSchema = z.infer<typeof getScheduleSchema>;
+export const ZGetScheduleInputSchema = getScheduleSchema;
+
export type GetScheduleOptions = {
ctx?: ContextForGetSchedule;
input: TGetScheduleInputSchema;