perf: fix circular dependencies (#20121)

* perf: fix circular dependencies

* fix: types

* fix: types

* fix: types

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
This commit is contained in:
Udit Takkarandsean-brydon authored and GitHub committed 2025-03-20 15:30:26 +00:00
1 parent b1b8b0135e
commit 55a97b71c8
18 files changed
+50 -56

No files matched your search

@@ -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> }>;
+1 -1
View File
@@ -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();
+16
View File
@@ -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;
};
};
@@ -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 {
@@ -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: {
@@ -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,
@@ -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,
@@ -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 };
@@ -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 }) {
@@ -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();
@@ -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,
+10
View File
@@ -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;
};
};
@@ -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[] = [
{
@@ -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 (
@@ -0,0 +1,6 @@
export type Template = {
icon: string;
app: string;
text: string;
link: string;
};
@@ -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;
@@ -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;
@@ -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;