feat: Upgrade to Next 15 (#18834)

* wip

* update layoutHOC

* wip

* remove app router related code no longer used

* remove more

* await cookies, headers, params, serachparams

* update yarn.lock

* await cookies, headers, params, serachparams more

* update yarn lock again

* downgrade next-auth to 4.22.1

* update yarn lock

* fix

* update yarn lock

* fix type checks

* update yarn lock

* await headers and cookies

* restore pages folder

* restore yarn.lock

* update yarn.lock

* await headers and cookies

* remove

* await params in API routes

* updates

* restore next.config.js

* remove i18n from next.config.js

* Fixed tests

* Fixed types

* Removed duplicate favicon.ico

* Fixing more types

* ImageResponse moved to next/og

* Fixed prisma import issues

* dynamic import for @ewsjs/xhr

* remove deasync dep

* dynamic import for @tryvital/vital-node

* fix type checks

* add back turbopack command

* Type fix

* Removed unneeded file

* fix turbopack relative path errors

* add comments

* remove unneeded code

* Fixed build errors

* await apis

* use Promise<Params> type in defaultResponderForAppDir util

* refactor scim api route

* fix type checks

* separate app-routing.config into client-config and server-config

* wip

* refactor routing forms components

* revert unneeded changes for easier review

* fix

* fix

* use CustomTrans

* fix type

* fix unit tests

* fix type error

* fix build error

* fix build error

* fix build error

* fix warnings

* fix warnings

* upgrade @tremor/react and tailwindcss

* numCols -> numItems

* fix forgot-password e2e test

* fix 1 more e2e test

* fix login e2e test

* fix e2e tests

* fix e2e tests

* clean up

* remove error

* use tremor/react 2.11.0

* fix

* rename CustomTrans to ServerTrans

* address comment

* fix test

* fix ServerTrans

* fix

* fix type

* fix ServerTrans usages 1

* fix translations

* fix type checks

* fix type checks

* link styling

* fix

---------

Co-authored-by: Keith Williams <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-03-20 21:30:51 -03:00
1 parent 695a4d7a59
commit 8ad442f2be
263 files changed
+2002 -1663

No files matched your search

@@ -1,3 +1,5 @@
"use client";
import Link from "next/link";
import { useEffect, useState } from "react";
import QRCode from "react-qr-code";
@@ -1,4 +1,3 @@
import { XhrApi } from "@ewsjs/xhr";
import type { FindFoldersResults, FindItemsResults } from "ews-javascript-api";
import {
Appointment,
@@ -55,7 +54,7 @@ export default class ExchangeCalendarService implements Calendar {
}
async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> {
const appointment: Appointment = new Appointment(this.getExchangeService());
const appointment: Appointment = new Appointment(await this.getExchangeService());
appointment.Subject = event.title;
appointment.Start = DateTime.Parse(event.startTime);
appointment.End = DateTime.Parse(event.endTime);
@@ -91,7 +90,7 @@ export default class ExchangeCalendarService implements Calendar {
uid: string,
event: CalendarEvent
): Promise<NewCalendarEventType | NewCalendarEventType[]> {
const appointment: Appointment = await Appointment.Bind(this.getExchangeService(), new ItemId(uid));
const appointment: Appointment = await Appointment.Bind(await this.getExchangeService(), new ItemId(uid));
appointment.Subject = event.title;
appointment.Start = DateTime.Parse(event.startTime);
appointment.End = DateTime.Parse(event.endTime);
@@ -127,7 +126,7 @@ export default class ExchangeCalendarService implements Calendar {
}
async deleteEvent(uid: string): Promise<void> {
const appointment: Appointment = await Appointment.Bind(this.getExchangeService(), new ItemId(uid));
const appointment: Appointment = await Appointment.Bind(await this.getExchangeService(), new ItemId(uid));
return appointment.Delete(DeleteMode.MoveToDeletedItems).catch((reason) => {
this.log.error(reason);
throw reason;
@@ -143,7 +142,7 @@ export default class ExchangeCalendarService implements Calendar {
const promises: Promise<EventBusyDate[]>[] = calendars
.filter((lcal) => selectedCalendars.some((rcal) => lcal.externalId == rcal.externalId))
.map(async (calendar) => {
return this.getExchangeService()
return (await this.getExchangeService())
.FindAppointments(
new FolderId(calendar.externalId),
new CalendarView(DateTime.Parse(dateFrom), DateTime.Parse(dateTo))
@@ -167,7 +166,7 @@ export default class ExchangeCalendarService implements Calendar {
}
async listCalendars(): Promise<IntegrationCalendar[]> {
const service: ExchangeService = this.getExchangeService();
const service: ExchangeService = await this.getExchangeService();
const view: FolderView = new FolderView(1000);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
view.PropertySet.Add(FolderSchema.ParentFolderId);
@@ -197,12 +196,13 @@ export default class ExchangeCalendarService implements Calendar {
});
}
private getExchangeService(): ExchangeService {
private async getExchangeService(): Promise<ExchangeService> {
const service: ExchangeService = new ExchangeService(this.payload.exchangeVersion);
service.Credentials = new WebCredentials(this.payload.username, this.payload.password);
service.Url = new Uri(this.payload.url);
if (this.payload.authenticationMethod === ExchangeAuthentication.NTLM) {
const xhr: XhrApi = new XhrApi({
const { XhrApi } = await import("@ewsjs/xhr");
const xhr = new XhrApi({
rejectUnauthorized: false,
}).useNtlmAuthentication(this.payload.username, this.payload.password);
service.XHRApi = xhr;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { TFunction } from "next-i18next";
import type { TFunction } from "i18next";
import { z } from "zod";
import { appStoreMetadata } from "@calcom/app-store/bookerAppsMetaData";
+20 -15
View File
@@ -1,5 +1,4 @@
import type { InferGetServerSidePropsType } from "next";
import { Trans } from "next-i18next";
import Link from "next/link";
import { useState } from "react";
import { Toaster } from "sonner";
@@ -11,6 +10,7 @@ import { Button } from "@calcom/ui/components/button";
import { Icon } from "@calcom/ui/components/icon";
import { showToast } from "@calcom/ui/components/toast";
import { Tooltip } from "@calcom/ui/components/tooltip";
import ServerTrans from "@calcom/web/components/ServerTrans";
import type { getServerSideProps } from "./_getServerSideProps";
@@ -115,20 +115,25 @@ export default function MakeSetup({ inviteLink }: InferGetServerSidePropsType<ty
</>
<ol className="mb-5 ml-5 mt-5 list-decimal ltr:mr-5 rtl:ml-5">
<Trans i18nKey="make_setup_instructions">
<li>
Go to
<a href={inviteLink} className="ml-1 mr-1 text-orange-600 underline">
Make Invite Link
</a>
and install the Cal.com app.
</li>
<li>Log into your Make account and create a new Scenario.</li>
<li>Select Cal.com as your Trigger app. Also choose a Trigger event.</li>
<li>Choose your account and then enter your Unique API Key.</li>
<li>Test your Trigger.</li>
<li>You&apos;re set!</li>
</Trans>
<li>
<ServerTrans
t={t}
i18nKey="make_setup_instructions_1"
components={[
<a
key="make-invite-link"
href={inviteLink}
className="ml-1 mr-1 text-orange-600 underline">
Make Invite Link
</a>,
]}
/>
</li>
<li>{t("make_setup_instructions_2")}</li>
<li>{t("make_setup_instructions_3")}</li>
<li>{t("make_setup_instructions_4")}</li>
<li>{t("make_setup_instructions_5")}</li>
<li>{t("make_setup_instructions_6")}</li>
</ol>
<Link href="/apps/installed/automation?hl=make" passHref={true} legacyBehavior>
<Button color="secondary">{t("done")}</Button>
@@ -114,7 +114,6 @@ export const getServerSidePropsForSingleFormView = async function getServerSideP
return {
props: {
trpcState: await ssr.dehydrate(),
form: await getSerializableForm({ form: formWithoutProfileInfo }),
enrichedWithUserProfileForm: await getSerializableForm({
form: enrichFormWithMigrationData(formWithUserInfoProfile),
@@ -0,0 +1,8 @@
export const routingFormsComponents = {
"form-edit": () => import("./form-edit/[...appPages]").then((mod) => mod.default),
"route-builder": () => import("./route-builder/[...appPages]").then((mod) => mod.default),
"forms": () => import("./forms/[...appPages]").then((mod) => mod.default),
"routing-link": () => import("./routing-link/[...appPages]").then((mod) => mod.default),
"reporting": () => import("./reporting/[...appPages]").then((mod) => mod.default),
"incomplete-booking": () => import("./incomplete-booking/[...appPages]").then((mod) => mod.default),
};
@@ -1,26 +1,11 @@
//TODO: Generate this file automatically so that like in Next.js file based routing can work automatically
import "server-only";
import type { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps";
import { getServerSidePropsForSingleFormView as getServerSidePropsSingleForm } from "../components/getServerSidePropsSingleForm";
import * as formEdit from "./form-edit/[...appPages]";
import * as forms from "./forms/[...appPages]";
// extracts getServerSideProps function from the client component
import { getServerSideProps as getServerSidePropsForms } from "./forms/getServerSideProps";
import * as IncompleteBooking from "./incomplete-booking/[...appPages]";
import * as Reporting from "./reporting/[...appPages]";
import * as RouteBuilder from "./route-builder/[...appPages]";
import * as RoutingLink from "./routing-link/[...appPages]";
import { getServerSideProps as getServerSidePropsRoutingLink } from "./routing-link/getServerSideProps";
const routingConfig = {
"form-edit": formEdit,
"route-builder": RouteBuilder,
forms: forms,
"routing-link": RoutingLink,
reporting: Reporting,
"incomplete-booking": IncompleteBooking,
};
export const routingServerSidePropsConfig: Record<string, AppGetServerSideProps> = {
forms: getServerSidePropsForms,
"form-edit": getServerSidePropsSingleForm,
@@ -29,5 +14,3 @@ export const routingServerSidePropsConfig: Record<string, AppGetServerSideProps>
reporting: getServerSidePropsSingleForm,
"incomplete-booking": getServerSidePropsSingleForm,
};
export default routingConfig;
@@ -30,8 +30,6 @@ export const getServerSideProps = async function getServerSideProps(
// Prefetch this so that New Button is immediately available
await ssr.viewer.teamsAndUserProfilesQuery.prefetch();
return {
props: {
trpcState: await ssr.dehydrate(),
},
props: {},
};
};
@@ -1,41 +0,0 @@
"use client";
import type { GetServerSidePropsContext, GetServerSideProps } from "next";
import type { ReactElement, ReactNode, ComponentType } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import RoutingFormsRoutingConfig from "../app-routing.config";
const DEFAULT_ROUTE = "forms";
type ComponentWithLayout = ComponentType & {
getLayout?: (page: ReactElement) => ReactNode;
};
type Component = {
default: ComponentWithLayout;
getServerSideProps?: (
context: GetServerSidePropsContext,
...rest: Parameters<GetServerSideProps>
) => ReturnType<GetServerSideProps>;
};
const getComponent = (route: string): Component => {
return (RoutingFormsRoutingConfig as unknown as Record<string, Component>)[route];
};
export default function LayoutHandler(props: { [key: string]: unknown }) {
const params = useParamsWithFallback();
const methods = useForm();
const pageKey = Array.isArray(params.pages)
? params.pages[0]
: params.pages?.split("/")[0] ?? DEFAULT_ROUTE;
const PageComponent = getComponent(pageKey).default;
return (
<FormProvider {...methods}>
<PageComponent {...props} />
</FormProvider>
);
}
+1 -1
View File
@@ -1,5 +1,5 @@
import type { Prisma } from "@prisma/client";
import type { TFunction } from "next-i18next";
import type { TFunction } from "i18next";
import { defaultVideoAppCategories } from "@calcom/app-store/utils";
import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";
+3 -3
View File
@@ -1,4 +1,3 @@
import { VitalClient } from "@tryvital/vital-node";
import type { ClientConfig } from "@tryvital/vital-node/dist/lib/models";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
@@ -8,10 +7,10 @@ type VitalEnv = ClientConfig & {
webhook_secret: string;
};
export let vitalClient: VitalClient | null = null;
export let vitalClient: any = null;
export let vitalEnv: VitalEnv | null = null;
export async function initVitalClient(): Promise<VitalClient> {
export async function initVitalClient() {
if (vitalClient) return vitalClient;
const appKeys = (await getAppKeysFromSlug("vital-automation")) as unknown as VitalEnv;
if (
@@ -23,6 +22,7 @@ export async function initVitalClient(): Promise<VitalClient> {
)
throw Error("Missing properties in vital-automation DB keys");
vitalEnv = appKeys;
const { VitalClient } = await import("@tryvital/vital-node");
vitalClient = new VitalClient({
region: appKeys.region,
api_key: appKeys.api_key || "",
+1 -1
View File
@@ -1,5 +1,5 @@
import type { Booking, BookingReference, User } from "@prisma/client";
import type { TFunction } from "next-i18next";
import type { TFunction } from "i18next";
import dayjs from "@calcom/dayjs";
import { sendRequestRescheduleEmailAndSMS } from "@calcom/emails";
@@ -1,5 +1,5 @@
import type { Booking, BookingReference, User } from "@prisma/client";
import type { TFunction } from "next-i18next";
import type { TFunction } from "i18next";
import dayjs from "@calcom/dayjs";
import { sendRequestRescheduleEmailAndSMS } from "@calcom/emails";
+16 -10
View File
@@ -1,4 +1,3 @@
import { Trans } from "next-i18next";
import Link from "next/link";
import { useState } from "react";
import { Toaster } from "sonner";
@@ -6,10 +5,11 @@ import { Toaster } from "sonner";
import AppNotInstalledMessage from "@calcom/app-store/_components/AppNotInstalledMessage";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Icon } from "@calcom/ui/components/icon";
import { Tooltip } from "@calcom/ui/components/tooltip";
import { Button } from "@calcom/ui/components/button";
import { Icon } from "@calcom/ui/components/icon";
import { showToast } from "@calcom/ui/components/toast";
import { Tooltip } from "@calcom/ui/components/tooltip";
import ServerTrans from "@calcom/web/components/ServerTrans";
export interface IZapierSetupProps {
inviteLink?: string;
@@ -124,13 +124,19 @@ export default function ZapierSetup(props: IZapierSetupProps) {
</a>
</li>
)}
<Trans i18nKey="zapier_setup_instructions">
<li>Log into your Zapier account and create a new Zap.</li>
<li>Select Cal.com as your Trigger app. Also choose a Trigger event.</li>
<li>Choose your account and then enter your Unique API Key.</li>
<li>Test your Trigger.</li>
<li>You&apos;re set!</li>
</Trans>
<ServerTrans
t={t}
i18nKey="zapier_setup_instructions"
components={[
<li key="instruction_1">Log into your Zapier account and create a new Zap.</li>,
<li key="instruction_2">
Select Cal.com as your Trigger app. Also choose a Trigger event.
</li>,
<li key="instruction_3">Choose your account and then enter your Unique API Key.</li>,
<li key="instruction_4">Test your Trigger.</li>,
<li key="instruction_5">You&apos;re set!</li>,
]}
/>
</ol>
<Link href="/apps/installed/automation?hl=zapier" passHref={true} legacyBehavior>
<Button color="secondary">{t("done")}</Button>