perf: Slim down logged in round 2 (#20535)
* perf: Slim down loggedInViewer some more * Move locationOptions to apps router * Moved calVideo related handlers to separate router * Moved calendar related handlers to separate router * Rename * Moved deleteCredential to new router * Moved updateProfile to me router * fix unit test * fix e2e test * tweak * missing --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: unknown <adhabal2002@gmail.com>
This commit is contained in:
co-authored by
Anik Dhabal Babu
unknown
parent
1953402f81
commit
e86ad03cde
@@ -84,16 +84,16 @@ export function CalendarListContainer(props: { heading?: boolean; fromOnboarding
|
||||
exact: true,
|
||||
}
|
||||
),
|
||||
utils.viewer.connectedCalendars.invalidate(),
|
||||
utils.viewer.calendars.connectedCalendars.invalidate(),
|
||||
]);
|
||||
const query = trpc.viewer.connectedCalendars.useQuery();
|
||||
const query = trpc.viewer.calendars.connectedCalendars.useQuery();
|
||||
const installedCalendars = trpc.viewer.apps.integrations.useQuery({
|
||||
variant: "calendar",
|
||||
onlyInstalled: true,
|
||||
});
|
||||
const mutation = trpc.viewer.setDestinationCalendar.useMutation({
|
||||
const mutation = trpc.viewer.calendars.setDestinationCalendar.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.viewer.connectedCalendars.invalidate();
|
||||
utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
},
|
||||
});
|
||||
return (
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useState } from "react";
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { AppRouter } from "@calcom/trpc/types/server/routers/_app";
|
||||
import type { AppRouter } from "@calcom/trpc/server/routers/_app";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
|
||||
import {
|
||||
@@ -36,7 +36,7 @@ export function MultiDisconnectIntegration({ credentials, onSuccess }: Props) {
|
||||
} | null>(null);
|
||||
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
|
||||
|
||||
const mutation = trpc.viewer.deleteCredential.useMutation({
|
||||
const mutation = trpc.viewer.credentials.delete.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("app_removed_successfully"), "success");
|
||||
onSuccess && onSuccess();
|
||||
@@ -47,7 +47,7 @@ export function MultiDisconnectIntegration({ credentials, onSuccess }: Props) {
|
||||
setConfirmationDialogOpen(false);
|
||||
},
|
||||
async onSettled() {
|
||||
await utils.viewer.connectedCalendars.invalidate();
|
||||
await utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
await utils.viewer.apps.integrations.invalidate();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -70,7 +70,7 @@ const LocationsWrapper = ({
|
||||
};
|
||||
|
||||
const EventTypeConferencingAppSettings = ({ eventType, slug }: { eventType: TEventType; slug: string }) => {
|
||||
const locationsQuery = trpc.viewer.locationOptions.useQuery({});
|
||||
const locationsQuery = trpc.viewer.apps.locationOptions.useQuery({});
|
||||
const { t } = useLocale();
|
||||
|
||||
const SkeletonLoader = () => {
|
||||
|
||||
@@ -92,7 +92,7 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
||||
teamId,
|
||||
} = props;
|
||||
const { t } = useLocale();
|
||||
const locationsQuery = trpc.viewer.locationOptions.useQuery({ teamId });
|
||||
const locationsQuery = trpc.viewer.apps.locationOptions.useQuery({ teamId });
|
||||
|
||||
useEffect(() => {
|
||||
if (selection) {
|
||||
|
||||
@@ -11,8 +11,10 @@ import { EditLocationDialog } from "../EditLocationDialog";
|
||||
vi.mock("@calcom/trpc/react", () => ({
|
||||
trpc: {
|
||||
viewer: {
|
||||
locationOptions: {
|
||||
useQuery: vi.fn(),
|
||||
apps: {
|
||||
locationOptions: {
|
||||
useQuery: vi.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,14 +4,14 @@ import type { RouterInputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
interface ICreateEventsOnCalendarSelectProps {
|
||||
calendar?: RouterInputs["viewer"]["setDestinationCalendar"] | null;
|
||||
calendar?: RouterInputs["viewer"]["calendars"]["setDestinationCalendar"] | null;
|
||||
}
|
||||
|
||||
const CreateEventsOnCalendarSelect = (props: ICreateEventsOnCalendarSelectProps) => {
|
||||
const { calendar } = props;
|
||||
const { t } = useLocale();
|
||||
const mutation = trpc.viewer.setDestinationCalendar.useMutation();
|
||||
const connectedCalendarsQuery = trpc.viewer.connectedCalendars.useQuery();
|
||||
const mutation = trpc.viewer.calendars.setDestinationCalendar.useMutation();
|
||||
const connectedCalendarsQuery = trpc.viewer.calendars.connectedCalendars.useQuery();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -16,7 +16,7 @@ interface IConnectCalendarsProps {
|
||||
|
||||
const ConnectedCalendars = (props: IConnectCalendarsProps) => {
|
||||
const { nextStep, isPageLoading } = props;
|
||||
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery({
|
||||
const queryConnectedCalendars = trpc.viewer.calendars.connectedCalendars.useQuery({
|
||||
onboarding: true,
|
||||
eventTypeId: null,
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ const UserProfile = () => {
|
||||
const [firstRender, setFirstRender] = useState(true);
|
||||
|
||||
// Create a separate mutation for avatar updates
|
||||
const avatarMutation = trpc.viewer.updateProfile.useMutation({
|
||||
const avatarMutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async (data) => {
|
||||
showToast(t("your_user_profile_updated_successfully"), "success");
|
||||
setImageSrc(data.avatarUrl ?? "");
|
||||
@@ -49,7 +49,7 @@ const UserProfile = () => {
|
||||
});
|
||||
|
||||
// Original mutation remains for onboarding completion
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async () => {
|
||||
try {
|
||||
if (eventTypes?.length === 0) {
|
||||
|
||||
@@ -58,7 +58,7 @@ const UserSettings = (props: IUserSettingsProps) => {
|
||||
await utils.viewer.me.invalidate();
|
||||
nextStep();
|
||||
};
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: onSuccess,
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const DisableUserImpersonation = ({ disableImpersonation }: { disableImpersonati
|
||||
|
||||
const { t } = useLocale();
|
||||
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async () => {
|
||||
showToast(t("your_user_profile_updated_successfully"), "success");
|
||||
await utils.viewer.me.invalidate();
|
||||
|
||||
@@ -102,7 +102,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
|
||||
checkUsername(debouncedUsername);
|
||||
}, [debouncedUsername, currentUsername]);
|
||||
|
||||
const updateUsername = trpc.viewer.updateProfile.useMutation({
|
||||
const updateUsername = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async () => {
|
||||
onSuccessMutation && (await onSuccessMutation());
|
||||
await update({ username: inputUsernameValue });
|
||||
|
||||
@@ -70,7 +70,7 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.Component
|
||||
checkUsername(debouncedUsername);
|
||||
}, [debouncedUsername, currentUsername]);
|
||||
|
||||
const updateUsernameMutation = trpc.viewer.updateProfile.useMutation({
|
||||
const updateUsernameMutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async () => {
|
||||
onSuccessMutation && (await onSuccessMutation());
|
||||
setOpenDialogSaveUsername(false);
|
||||
|
||||
@@ -207,7 +207,7 @@ export default function InstalledApps({ category }: PageProps) {
|
||||
updateData({ isOpen: true, credentialId, teamId });
|
||||
};
|
||||
|
||||
const deleteCredentialMutation = trpc.viewer.deleteCredential.useMutation();
|
||||
const deleteCredentialMutation = trpc.viewer.credentials.delete.useMutation();
|
||||
|
||||
const handleRemoveApp = ({ credentialId, teamId, callback }: RemoveAppParams) => {
|
||||
deleteCredentialMutation.mutate(
|
||||
@@ -217,7 +217,7 @@ export default function InstalledApps({ category }: PageProps) {
|
||||
showToast(t("app_removed_successfully"), "success");
|
||||
callback();
|
||||
utils.viewer.apps.integrations.invalidate();
|
||||
utils.viewer.connectedCalendars.invalidate();
|
||||
utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_removing_app"), "error");
|
||||
|
||||
@@ -155,7 +155,7 @@ const AppearanceView = ({
|
||||
typeof document !== "undefined" &&
|
||||
document.documentElement.classList.contains("dark"));
|
||||
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async (data) => {
|
||||
await utils.viewer.me.invalidate();
|
||||
showToast(t("settings_updated_successfully"), "success");
|
||||
|
||||
@@ -103,7 +103,7 @@ const GeneralView = ({ localeProp, user, travelSchedules, revalidatePage }: Gene
|
||||
const [isUpdateBtnLoading, setIsUpdateBtnLoading] = useState<boolean>(false);
|
||||
const [isTZScheduleOpen, setIsTZScheduleOpen] = useState<boolean>(false);
|
||||
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async (res) => {
|
||||
await utils.viewer.me.invalidate();
|
||||
reset(getValues());
|
||||
|
||||
@@ -94,7 +94,7 @@ const ProfileView = () => {
|
||||
const { update } = useSession();
|
||||
const { data: user, isPending } = trpc.viewer.me.get.useQuery({ includePasswordAdded: true });
|
||||
|
||||
const updateProfileMutation = trpc.viewer.updateProfile.useMutation({
|
||||
const updateProfileMutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async (res) => {
|
||||
await update(res);
|
||||
utils.viewer.me.invalidate();
|
||||
|
||||
@@ -26,7 +26,7 @@ const ProfileImpersonationView = ({ user }: { user: RouterOutputs["viewer"]["me"
|
||||
user?.disableImpersonation
|
||||
);
|
||||
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("profile_updated_successfully"), "success");
|
||||
},
|
||||
|
||||
@@ -11,19 +11,14 @@ import { IdentityProvider } from "@calcom/prisma/enums";
|
||||
import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { PasswordField } from "@calcom/ui/components/form";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import { SettingsToggle } from "@calcom/ui/components/form";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import {
|
||||
SkeletonButton,
|
||||
SkeletonContainer,
|
||||
SkeletonText,
|
||||
SkeletonAvatar,
|
||||
} from "@calcom/ui/components/skeleton";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
type ChangePasswordSessionFormValues = {
|
||||
@@ -63,7 +58,7 @@ const PasswordView = ({ user }: PasswordViewProps) => {
|
||||
|
||||
const [sessionTimeout, setSessionTimeout] = useState<number | undefined>(initialSessionTimeout);
|
||||
|
||||
const sessionMutation = trpc.viewer.updateProfile.useMutation({
|
||||
const sessionMutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: (data) => {
|
||||
showToast(t("session_timeout_changed"), "success");
|
||||
formMethods.reset(formMethods.getValues());
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler";
|
||||
import { calVideoRouter } from "@calcom/trpc/server/routers/viewer/calVideo/_router";
|
||||
|
||||
export default createNextApiHandler(calVideoRouter);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler";
|
||||
import { calendarsRouter } from "@calcom/trpc/server/routers/viewer/calendars/_router";
|
||||
|
||||
export default createNextApiHandler(calendarsRouter);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler";
|
||||
import { credentialsRouter } from "@calcom/trpc/server/routers/viewer/credentials/_router";
|
||||
|
||||
export default createNextApiHandler(credentialsRouter);
|
||||
@@ -41,7 +41,7 @@ test.describe("Change username on settings", () => {
|
||||
|
||||
await usernameInput.fill(item.username);
|
||||
await page.click("[data-testid=update-username-btn]");
|
||||
await submitAndWaitForResponse(page, "/api/trpc/viewer/updateProfile?batch=1", {
|
||||
await submitAndWaitForResponse(page, "/api/trpc/me/updateProfile?batch=1", {
|
||||
action: () => page.click("[data-testid=save-username]"),
|
||||
});
|
||||
|
||||
|
||||
@@ -448,7 +448,7 @@ test.describe("authorized user sees changed translations (de->ar)", async () =>
|
||||
await page.locator(".bg-default > div > div:nth-child(2)").first().click();
|
||||
await page.getByTestId("select-option-ar").click();
|
||||
|
||||
await submitAndWaitForResponse(page, "/api/trpc/viewer/updateProfile?batch=1", {
|
||||
await submitAndWaitForResponse(page, "/api/trpc/me/updateProfile?batch=1", {
|
||||
action: () => page.click("[data-testid=general-submit-button]"),
|
||||
});
|
||||
|
||||
@@ -508,7 +508,7 @@ test.describe("authorized user sees changed translations (de->pt-BR) [locale1]",
|
||||
await page.locator(".bg-default > div > div:nth-child(2)").first().click();
|
||||
await page.locator("text=Português (Brasil)").click();
|
||||
|
||||
await submitAndWaitForResponse(page, "/api/trpc/viewer/updateProfile?batch=1", {
|
||||
await submitAndWaitForResponse(page, "/api/trpc/me/updateProfile?batch=1", {
|
||||
action: () => page.click("[data-testid=general-submit-button]"),
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ test.describe("Update Profile", () => {
|
||||
|
||||
await page.getByTestId("password").fill(user?.username ?? "Nameless User");
|
||||
|
||||
await submitAndWaitForResponse(page, "/api/trpc/viewer/updateProfile?batch=1", {
|
||||
await submitAndWaitForResponse(page, "/api/trpc/me/updateProfile?batch=1", {
|
||||
action: () => page.getByTestId("profile-update-email-submit-button").click(),
|
||||
});
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ function HitPaySetupPage(props: IHitPaySetupProps) {
|
||||
},
|
||||
});
|
||||
|
||||
const deleteMutation = trpc.viewer.deleteCredential.useMutation({
|
||||
const deleteMutation = trpc.viewer.credentials.delete.useMutation({
|
||||
onSuccess: () => {
|
||||
router.push("/apps/hitpay");
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function DisconnectIntegration(props: {
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const mutation = trpc.viewer.deleteCredential.useMutation({
|
||||
const mutation = trpc.viewer.credentials.delete.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("app_removed_successfully"), "success");
|
||||
setModalOpen(false);
|
||||
@@ -34,7 +34,7 @@ export default function DisconnectIntegration(props: {
|
||||
setModalOpen(false);
|
||||
},
|
||||
async onSettled() {
|
||||
await utils.viewer.connectedCalendars.invalidate();
|
||||
await utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
await utils.viewer.apps.integrations.invalidate();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ export const useCalendars = ({ hasSession }: UseCalendarsProps) => {
|
||||
[isError]
|
||||
);
|
||||
|
||||
const { data, isPending } = trpc.viewer.connectedCalendars.useQuery(undefined, {
|
||||
const { data, isPending } = trpc.viewer.calendars.connectedCalendars.useQuery(undefined, {
|
||||
enabled: !!calendarSettingsOverlay || Boolean(searchParams?.get("overlayCalendar")),
|
||||
});
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => {
|
||||
},
|
||||
async onSettled() {
|
||||
await utils.viewer.apps.integrations.invalidate();
|
||||
await utils.viewer.connectedCalendars.invalidate();
|
||||
await utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
},
|
||||
onError() {
|
||||
setCheckedInternal(false);
|
||||
|
||||
@@ -18,7 +18,7 @@ interface Props {
|
||||
value: string | undefined;
|
||||
maxWidth?: number;
|
||||
hideAdvancedText?: boolean;
|
||||
calendarsQueryData?: RouterOutputs["viewer"]["connectedCalendars"];
|
||||
calendarsQueryData?: RouterOutputs["viewer"]["calendars"]["connectedCalendars"];
|
||||
customClassNames?: SelectClassNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ const getTimeSpan = ({ startTime, endTime, locale, hour12 }: GetTimeSpanProps) =
|
||||
|
||||
const useRecordingDownload = () => {
|
||||
const [recordingId, setRecordingId] = useState("");
|
||||
const { isFetching, data } = trpc.viewer.getDownloadLinkOfCalVideoRecordings.useQuery(
|
||||
const { isFetching, data } = trpc.viewer.calVideo.getDownloadLinkOfCalVideoRecordings.useQuery(
|
||||
{
|
||||
recordingId,
|
||||
},
|
||||
@@ -100,7 +100,7 @@ const ViewRecordingsList = ({ roomName, hasTeamPlan }: { roomName: string; hasTe
|
||||
const { setRecordingId, isFetching, recordingId } = useRecordingDownload();
|
||||
const router = useRouter();
|
||||
|
||||
const { data: recordings } = trpc.viewer.getCalVideoRecordings.useQuery(
|
||||
const { data: recordings } = trpc.viewer.calVideo.getCalVideoRecordings.useQuery(
|
||||
{ roomName },
|
||||
{
|
||||
suspense: true,
|
||||
|
||||
@@ -66,7 +66,7 @@ export default function WorkflowListPage({ workflows }: Props) {
|
||||
const [parent] = useAutoAnimate<HTMLUListElement>();
|
||||
const router = useRouter();
|
||||
|
||||
const mutation = trpc.viewer.workflowOrder.useMutation({
|
||||
const mutation = trpc.viewer.workflows.workflowOrder.useMutation({
|
||||
onError: async (err) => {
|
||||
console.error(err.message);
|
||||
await utils.viewer.workflows.filteredList.cancel();
|
||||
|
||||
@@ -115,7 +115,7 @@ export type EventAdvancedBaseProps = Pick<EventTypeSetupProps, "eventType" | "te
|
||||
|
||||
export type EventAdvancedTabProps = EventAdvancedBaseProps & {
|
||||
calendarsQuery: {
|
||||
data?: RouterOutputs["viewer"]["connectedCalendars"];
|
||||
data?: RouterOutputs["viewer"]["calendars"]["connectedCalendars"];
|
||||
isPending: boolean;
|
||||
error: unknown;
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ const TimezoneChangeDialogContent = () => {
|
||||
};
|
||||
|
||||
// update timezone in db
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
const mutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: onMutationSuccess,
|
||||
onError: onMutationError,
|
||||
});
|
||||
|
||||
@@ -81,7 +81,7 @@ function EmptyCalendarToggleItem() {
|
||||
|
||||
export function CalendarToggleContainer() {
|
||||
const { t } = useLocale();
|
||||
const { data, isLoading } = trpc.viewer.connectedCalendars.useQuery();
|
||||
const { data, isLoading } = trpc.viewer.calendars.connectedCalendars.useQuery();
|
||||
|
||||
const hasConnectedCalendars = data && data?.connectedCalendars.length > 0;
|
||||
|
||||
|
||||
+2
-2
@@ -183,7 +183,7 @@ export const ConferencingAppsViewWebWrapper = ({
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const deleteCredentialMutation = trpc.viewer.deleteCredential.useMutation();
|
||||
const deleteCredentialMutation = trpc.viewer.credentials.delete.useMutation();
|
||||
|
||||
const handleRemoveApp = ({ credentialId, teamId, callback }: RemoveAppParams) => {
|
||||
deleteCredentialMutation.mutate(
|
||||
@@ -193,7 +193,7 @@ export const ConferencingAppsViewWebWrapper = ({
|
||||
showToast(t("app_removed_successfully"), "success");
|
||||
callback();
|
||||
utils.viewer.apps.integrations.invalidate();
|
||||
utils.viewer.connectedCalendars.invalidate();
|
||||
utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_removing_app"), "error");
|
||||
|
||||
+3
-3
@@ -4,11 +4,11 @@ import { AtomsWrapper } from "../../src/components/atoms-wrapper";
|
||||
import { DestinationCalendarSettings } from "../DestinationCalendar";
|
||||
|
||||
export const DestinationCalendarSettingsWebWrapper = () => {
|
||||
const calendars = trpc.viewer.connectedCalendars.useQuery();
|
||||
const calendars = trpc.viewer.calendars.connectedCalendars.useQuery();
|
||||
const utils = trpc.useUtils();
|
||||
const mutation = trpc.viewer.setDestinationCalendar.useMutation({
|
||||
const mutation = trpc.viewer.calendars.setDestinationCalendar.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.viewer.connectedCalendars.invalidate();
|
||||
utils.viewer.calendars.connectedCalendars.invalidate();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { EventAdvancedTab } from "@calcom/features/eventtypes/components/tabs/ad
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
const EventAdvancedWebWrapper = ({ ...props }: EventAdvancedBaseProps) => {
|
||||
const connectedCalendarsQuery = trpc.viewer.connectedCalendars.useQuery();
|
||||
const connectedCalendarsQuery = trpc.viewer.calendars.connectedCalendars.useQuery();
|
||||
return (
|
||||
<EventAdvancedTab
|
||||
{...props}
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ const ConnectedCalendarList = ({
|
||||
}: {
|
||||
fromOnboarding?: boolean;
|
||||
scope: SelectedCalendarSettingsScope;
|
||||
items: RouterOutputs["viewer"]["connectedCalendars"]["connectedCalendars"];
|
||||
items: RouterOutputs["viewer"]["calendars"]["connectedCalendars"]["connectedCalendars"];
|
||||
disableConnectionModification?: boolean;
|
||||
eventTypeId: number | null;
|
||||
onChanged?: () => unknown | Promise<unknown>;
|
||||
@@ -152,7 +152,7 @@ export const SelectedCalendarsSettingsWebWrapper = (props: SelectedCalendarsSett
|
||||
eventTypeId = null,
|
||||
} = props;
|
||||
|
||||
const query = trpc.viewer.connectedCalendars.useQuery(
|
||||
const query = trpc.viewer.calendars.connectedCalendars.useQuery(
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
eventTypeId: scope === SelectedCalendarSettingsScope.EventType ? eventTypeId! : null,
|
||||
|
||||
@@ -9,6 +9,9 @@ export const ENDPOINTS = [
|
||||
"availability",
|
||||
"appBasecamp3",
|
||||
"bookings",
|
||||
"calendars",
|
||||
"calVideo",
|
||||
"credentials",
|
||||
"deploymentSetup",
|
||||
"dsync",
|
||||
"eventTypes",
|
||||
|
||||
@@ -3,38 +3,22 @@ import { importHandler, router } from "../../trpc";
|
||||
import { ZAddNotificationsSubscriptionInputSchema } from "./addNotificationsSubscription.schema";
|
||||
import { ZAddSecondaryEmailInputSchema } from "./addSecondaryEmail.schema";
|
||||
import { ZConnectAndJoinInputSchema } from "./connectAndJoin.schema";
|
||||
import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
||||
import { ZDeleteCredentialInputSchema } from "./deleteCredential.schema";
|
||||
import { ZEventTypeOrderInputSchema } from "./eventTypeOrder.schema";
|
||||
import { ZGetCalVideoRecordingsInputSchema } from "./getCalVideoRecordings.schema";
|
||||
import { ZGetDownloadLinkOfCalVideoRecordingsInputSchema } from "./getDownloadLinkOfCalVideoRecordings.schema";
|
||||
import { ZLocationOptionsInputSchema } from "./locationOptions.schema";
|
||||
import { ZNoShowInputSchema } from "./markNoShow.schema";
|
||||
import { teamsAndUserProfilesQuery } from "./procedures/teamsAndUserProfilesQuery";
|
||||
import { ZRemoveNotificationsSubscriptionInputSchema } from "./removeNotificationsSubscription.schema";
|
||||
import { ZRoutingFormOrderInputSchema } from "./routingFormOrder.schema";
|
||||
import { ZSetDestinationCalendarInputSchema } from "./setDestinationCalendar.schema";
|
||||
import { ZSubmitFeedbackInputSchema } from "./submitFeedback.schema";
|
||||
import { ZUpdateProfileInputSchema } from "./updateProfile.schema";
|
||||
import { ZWorkflowOrderInputSchema } from "./workflowOrder.schema";
|
||||
|
||||
const NAMESPACE = "loggedInViewer";
|
||||
|
||||
const namespaced = (s: string) => `${NAMESPACE}.${s}`;
|
||||
|
||||
type AppsRouterHandlerCache = {
|
||||
connectedCalendars?: typeof import("./connectedCalendars.handler").connectedCalendarsHandler;
|
||||
setDestinationCalendar?: typeof import("./setDestinationCalendar.handler").setDestinationCalendarHandler;
|
||||
stripeCustomer?: typeof import("./stripeCustomer.handler").stripeCustomerHandler;
|
||||
updateProfile?: typeof import("./updateProfile.handler").updateProfileHandler;
|
||||
eventTypeOrder?: typeof import("./eventTypeOrder.handler").eventTypeOrderHandler;
|
||||
routingFormOrder?: typeof import("./routingFormOrder.handler").routingFormOrderHandler;
|
||||
workflowOrder?: typeof import("./workflowOrder.handler").workflowOrderHandler;
|
||||
submitFeedback?: typeof import("./submitFeedback.handler").submitFeedbackHandler;
|
||||
locationOptions?: typeof import("./locationOptions.handler").locationOptionsHandler;
|
||||
deleteCredential?: typeof import("./deleteCredential.handler").deleteCredentialHandler;
|
||||
getCalVideoRecordings?: typeof import("./getCalVideoRecordings.handler").getCalVideoRecordingsHandler;
|
||||
getDownloadLinkOfCalVideoRecordings?: typeof import("./getDownloadLinkOfCalVideoRecordings.handler").getDownloadLinkOfCalVideoRecordingsHandler;
|
||||
teamsAndUserProfilesQuery?: typeof import("./teamsAndUserProfilesQuery.handler").teamsAndUserProfilesQuery;
|
||||
connectAndJoin?: typeof import("./connectAndJoin.handler").Handler;
|
||||
addSecondaryEmail?: typeof import("./addSecondaryEmail.handler").addSecondaryEmailHandler;
|
||||
@@ -46,38 +30,6 @@ type AppsRouterHandlerCache = {
|
||||
const UNSTABLE_HANDLER_CACHE: AppsRouterHandlerCache = {};
|
||||
|
||||
export const loggedInViewerRouter = router({
|
||||
connectedCalendars: authedProcedure.input(ZConnectedCalendarsInputSchema).query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
||||
UNSTABLE_HANDLER_CACHE.connectedCalendars = (
|
||||
await import("./connectedCalendars.handler")
|
||||
).connectedCalendarsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.connectedCalendars({ ctx, input });
|
||||
}),
|
||||
|
||||
setDestinationCalendar: authedProcedure
|
||||
.input(ZSetDestinationCalendarInputSchema)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.setDestinationCalendar) {
|
||||
UNSTABLE_HANDLER_CACHE.setDestinationCalendar = (
|
||||
await import("./setDestinationCalendar.handler")
|
||||
).setDestinationCalendarHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.setDestinationCalendar) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.setDestinationCalendar({ ctx, input });
|
||||
}),
|
||||
|
||||
stripeCustomer: authedProcedure.query(async ({ ctx }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.stripeCustomer) {
|
||||
UNSTABLE_HANDLER_CACHE.stripeCustomer = (
|
||||
@@ -93,19 +45,6 @@ export const loggedInViewerRouter = router({
|
||||
return UNSTABLE_HANDLER_CACHE.stripeCustomer({ ctx });
|
||||
}),
|
||||
|
||||
updateProfile: authedProcedure.input(ZUpdateProfileInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.updateProfile) {
|
||||
UNSTABLE_HANDLER_CACHE.updateProfile = (await import("./updateProfile.handler")).updateProfileHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.updateProfile) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.updateProfile({ ctx, input });
|
||||
}),
|
||||
|
||||
unlinkConnectedAccount: authedProcedure.mutation(async (opts) => {
|
||||
const handler = await importHandler(
|
||||
namespaced("unlinkConnectedAccount"),
|
||||
@@ -144,19 +83,6 @@ export const loggedInViewerRouter = router({
|
||||
return UNSTABLE_HANDLER_CACHE.routingFormOrder({ ctx, input });
|
||||
}),
|
||||
|
||||
workflowOrder: authedProcedure.input(ZWorkflowOrderInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.workflowOrder) {
|
||||
UNSTABLE_HANDLER_CACHE.workflowOrder = (await import("./workflowOrder.handler")).workflowOrderHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.workflowOrder) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.workflowOrder({ ctx, input });
|
||||
}),
|
||||
|
||||
//Comment for PR: eventTypePosition is not used anywhere
|
||||
submitFeedback: authedProcedure.input(ZSubmitFeedbackInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.submitFeedback) {
|
||||
@@ -172,70 +98,6 @@ export const loggedInViewerRouter = router({
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.submitFeedback({ ctx, input });
|
||||
}),
|
||||
|
||||
locationOptions: authedProcedure.input(ZLocationOptionsInputSchema).query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.locationOptions) {
|
||||
UNSTABLE_HANDLER_CACHE.locationOptions = (
|
||||
await import("./locationOptions.handler")
|
||||
).locationOptionsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.locationOptions) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.locationOptions({ ctx, input });
|
||||
}),
|
||||
|
||||
deleteCredential: authedProcedure.input(ZDeleteCredentialInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.deleteCredential) {
|
||||
UNSTABLE_HANDLER_CACHE.deleteCredential = (
|
||||
await import("./deleteCredential.handler")
|
||||
).deleteCredentialHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.deleteCredential) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.deleteCredential({ ctx, input });
|
||||
}),
|
||||
|
||||
getCalVideoRecordings: authedProcedure
|
||||
.input(ZGetCalVideoRecordingsInputSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.getCalVideoRecordings) {
|
||||
UNSTABLE_HANDLER_CACHE.getCalVideoRecordings = (
|
||||
await import("./getCalVideoRecordings.handler")
|
||||
).getCalVideoRecordingsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.getCalVideoRecordings) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.getCalVideoRecordings({ ctx, input });
|
||||
}),
|
||||
|
||||
getDownloadLinkOfCalVideoRecordings: authedProcedure
|
||||
.input(ZGetDownloadLinkOfCalVideoRecordingsInputSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings) {
|
||||
UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings = (
|
||||
await import("./getDownloadLinkOfCalVideoRecordings.handler")
|
||||
).getDownloadLinkOfCalVideoRecordingsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings({ ctx, input });
|
||||
}),
|
||||
teamsAndUserProfilesQuery,
|
||||
connectAndJoin: authedProcedure.input(ZConnectAndJoinInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.connectAndJoin) {
|
||||
|
||||
@@ -15,6 +15,9 @@ import { attributesRouter } from "./attributes/_router";
|
||||
import { authRouter } from "./auth/_router";
|
||||
import { availabilityRouter } from "./availability/_router";
|
||||
import { bookingsRouter } from "./bookings/_router";
|
||||
import { calVideoRouter } from "./calVideo/_router";
|
||||
import { calendarsRouter } from "./calendars/_router";
|
||||
import { credentialsRouter } from "./credentials/_router";
|
||||
import { delegationCredentialRouter } from "./delegationCredential/_router";
|
||||
import { deploymentSetupRouter } from "./deploymentSetup/_router";
|
||||
import { dsyncRouter } from "./dsync/_router";
|
||||
@@ -46,6 +49,9 @@ export const viewerRouter = mergeRouters(
|
||||
auth: authRouter,
|
||||
deploymentSetup: deploymentSetupRouter,
|
||||
bookings: bookingsRouter,
|
||||
calendars: calendarsRouter,
|
||||
calVideo: calVideoRouter,
|
||||
credentials: credentialsRouter,
|
||||
eventTypes: eventTypesRouter,
|
||||
availability: availabilityRouter,
|
||||
teams: viewerTeamsRouter,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ZAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema"
|
||||
import { checkGlobalKeysSchema } from "./checkGlobalKeys.schema";
|
||||
import { ZIntegrationsInputSchema } from "./integrations.schema";
|
||||
import { ZListLocalInputSchema } from "./listLocal.schema";
|
||||
import { ZLocationOptionsInputSchema } from "./locationOptions.schema";
|
||||
import { ZQueryForDependenciesInputSchema } from "./queryForDependencies.schema";
|
||||
import { ZSaveKeysInputSchema } from "./saveKeys.schema";
|
||||
import { ZSetDefaultConferencingAppSchema } from "./setDefaultConferencingApp.schema";
|
||||
@@ -18,6 +19,7 @@ type AppsRouterHandlerCache = {
|
||||
getUsersDefaultConferencingApp?: typeof import("./getUsersDefaultConferencingApp.handler").getUsersDefaultConferencingAppHandler;
|
||||
integrations?: typeof import("./integrations.handler").integrationsHandler;
|
||||
listLocal?: typeof import("./listLocal.handler").listLocalHandler;
|
||||
locationOptions?: typeof import("./locationOptions.handler").locationOptionsHandler;
|
||||
toggle?: typeof import("./toggle.handler").toggleHandler;
|
||||
saveKeys?: typeof import("./saveKeys.handler").saveKeysHandler;
|
||||
checkForGCal?: typeof import("./checkForGCal.handler").checkForGCalHandler;
|
||||
@@ -86,6 +88,7 @@ export const appsRouter = router({
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.integrations({ ctx, input });
|
||||
}),
|
||||
|
||||
listLocal: authedAdminProcedure.input(ZListLocalInputSchema).query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.listLocal) {
|
||||
UNSTABLE_HANDLER_CACHE.listLocal = await import("./listLocal.handler").then(
|
||||
@@ -104,6 +107,21 @@ export const appsRouter = router({
|
||||
});
|
||||
}),
|
||||
|
||||
locationOptions: authedProcedure.input(ZLocationOptionsInputSchema).query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.locationOptions) {
|
||||
UNSTABLE_HANDLER_CACHE.locationOptions = (
|
||||
await import("./locationOptions.handler")
|
||||
).locationOptionsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.locationOptions) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.locationOptions({ ctx, input });
|
||||
}),
|
||||
|
||||
toggle: authedAdminProcedure.input(ZToggleInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.toggle) {
|
||||
UNSTABLE_HANDLER_CACHE.toggle = await import("./toggle.handler").then((mod) => mod.toggleHandler);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import authedProcedure from "../../../procedures/authedProcedure";
|
||||
import { router } from "../../../trpc";
|
||||
import { ZGetCalVideoRecordingsInputSchema } from "./getCalVideoRecordings.schema";
|
||||
import { ZGetDownloadLinkOfCalVideoRecordingsInputSchema } from "./getDownloadLinkOfCalVideoRecordings.schema";
|
||||
|
||||
type CalVideoRouterHandlerCache = {
|
||||
getCalVideoRecordings?: typeof import("./getCalVideoRecordings.handler").getCalVideoRecordingsHandler;
|
||||
getDownloadLinkOfCalVideoRecordings?: typeof import("./getDownloadLinkOfCalVideoRecordings.handler").getDownloadLinkOfCalVideoRecordingsHandler;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: CalVideoRouterHandlerCache = {};
|
||||
|
||||
export const calVideoRouter = router({
|
||||
getCalVideoRecordings: authedProcedure
|
||||
.input(ZGetCalVideoRecordingsInputSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.getCalVideoRecordings) {
|
||||
UNSTABLE_HANDLER_CACHE.getCalVideoRecordings = (
|
||||
await import("./getCalVideoRecordings.handler")
|
||||
).getCalVideoRecordingsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.getCalVideoRecordings) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.getCalVideoRecordings({ ctx, input });
|
||||
}),
|
||||
|
||||
getDownloadLinkOfCalVideoRecordings: authedProcedure
|
||||
.input(ZGetDownloadLinkOfCalVideoRecordingsInputSchema)
|
||||
.query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings) {
|
||||
UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings = (
|
||||
await import("./getDownloadLinkOfCalVideoRecordings.handler")
|
||||
).getDownloadLinkOfCalVideoRecordingsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.getDownloadLinkOfCalVideoRecordings({ ctx, input });
|
||||
}),
|
||||
});
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { getDownloadLinkOfCalVideoByRecordingId } from "@calcom/lib/videoClient"
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import type { WithSession } from "../../createContext";
|
||||
import type { WithSession } from "../../../createContext";
|
||||
import type { TGetDownloadLinkOfCalVideoRecordingsInputSchema } from "./getDownloadLinkOfCalVideoRecordings.schema";
|
||||
|
||||
type GetDownloadLinkOfCalVideoRecordingsHandlerOptions = {
|
||||
@@ -0,0 +1,45 @@
|
||||
import authedProcedure from "../../../procedures/authedProcedure";
|
||||
import { router } from "../../../trpc";
|
||||
import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
||||
import { ZSetDestinationCalendarInputSchema } from "./setDestinationCalendar.schema";
|
||||
|
||||
type CalendarsRouterHandlerCache = {
|
||||
connectedCalendars?: typeof import("./connectedCalendars.handler").connectedCalendarsHandler;
|
||||
setDestinationCalendar?: typeof import("./setDestinationCalendar.handler").setDestinationCalendarHandler;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: CalendarsRouterHandlerCache = {};
|
||||
|
||||
export const calendarsRouter = router({
|
||||
connectedCalendars: authedProcedure.input(ZConnectedCalendarsInputSchema).query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
||||
UNSTABLE_HANDLER_CACHE.connectedCalendars = (
|
||||
await import("./connectedCalendars.handler")
|
||||
).connectedCalendarsHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.connectedCalendars({ ctx, input });
|
||||
}),
|
||||
|
||||
setDestinationCalendar: authedProcedure
|
||||
.input(ZSetDestinationCalendarInputSchema)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.setDestinationCalendar) {
|
||||
UNSTABLE_HANDLER_CACHE.setDestinationCalendar = (
|
||||
await import("./setDestinationCalendar.handler")
|
||||
).setDestinationCalendarHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.setDestinationCalendar) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.setDestinationCalendar({ ctx, input });
|
||||
}),
|
||||
});
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import prisma from "../../../../../tests/libs/__mocks__/prisma";
|
||||
import prisma from "../../../../../../tests/libs/__mocks__/prisma";
|
||||
|
||||
import {
|
||||
createBookingScenario,
|
||||
@@ -17,7 +17,7 @@ import { SchedulingType, MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import type { TrpcSessionUser } from "../../types";
|
||||
import type { TrpcSessionUser } from "../../../types";
|
||||
import { setDestinationCalendarHandler } from "./setDestinationCalendar.handler";
|
||||
|
||||
vi.mock("@calcom/lib/CalendarManager", () => ({
|
||||
@@ -0,0 +1,26 @@
|
||||
import authedProcedure from "../../../procedures/authedProcedure";
|
||||
import { router } from "../../../trpc";
|
||||
import { ZDeleteCredentialInputSchema } from "./deleteCredential.schema";
|
||||
|
||||
type CredentialsRouterHandlerCache = {
|
||||
deleteCredential?: typeof import("./deleteCredential.handler").deleteCredentialHandler;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: CredentialsRouterHandlerCache = {};
|
||||
|
||||
export const credentialsRouter = router({
|
||||
delete: authedProcedure.input(ZDeleteCredentialInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.deleteCredential) {
|
||||
UNSTABLE_HANDLER_CACHE.deleteCredential = (
|
||||
await import("./deleteCredential.handler")
|
||||
).deleteCredentialHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.deleteCredential) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.deleteCredential({ ctx, input });
|
||||
}),
|
||||
});
|
||||
@@ -7,7 +7,7 @@ import { prisma } from "@calcom/prisma";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../types";
|
||||
import { setDestinationCalendarHandler } from "../../loggedInViewer/setDestinationCalendar.handler";
|
||||
import { setDestinationCalendarHandler } from "../../viewer/calendars/setDestinationCalendar.handler";
|
||||
import type { TDuplicateInputSchema } from "./duplicate.schema";
|
||||
|
||||
type DuplicateOptions = {
|
||||
|
||||
@@ -20,7 +20,7 @@ import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../types";
|
||||
import { setDestinationCalendarHandler } from "../../loggedInViewer/setDestinationCalendar.handler";
|
||||
import { setDestinationCalendarHandler } from "../../viewer/calendars/setDestinationCalendar.handler";
|
||||
import type { TUpdateInputSchema } from "./update.schema";
|
||||
import {
|
||||
ensureUniqueBookingFields,
|
||||
|
||||
@@ -2,6 +2,7 @@ import authedProcedure from "../../../procedures/authedProcedure";
|
||||
import { router } from "../../../trpc";
|
||||
import { ZDeleteMeInputSchema } from "./deleteMe.schema";
|
||||
import { get } from "./procedures/get";
|
||||
import { ZUpdateProfileInputSchema } from "./updateProfile.schema";
|
||||
|
||||
export const meRouter = router({
|
||||
bookingUnconfirmedCount: authedProcedure.query(async ({ ctx }) => {
|
||||
@@ -33,4 +34,8 @@ export const meRouter = router({
|
||||
const handler = (await import("./shouldVerifyEmail.handler")).shouldVerifyEmailHandler;
|
||||
return handler({ ctx });
|
||||
}),
|
||||
updateProfile: authedProcedure.input(ZUpdateProfileInputSchema).mutation(async ({ ctx, input }) => {
|
||||
const handler = (await import("./updateProfile.handler")).updateProfileHandler;
|
||||
return handler({ ctx, input });
|
||||
}),
|
||||
});
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import { getDefaultScheduleId } from "../viewer/availability/util";
|
||||
import { getDefaultScheduleId } from "../availability/util";
|
||||
import { updateUserMetadataAllowedKeys, type TUpdateProfileInputSchema } from "./updateProfile.schema";
|
||||
|
||||
const log = logger.getSubLogger({ prefix: ["updateProfile"] });
|
||||
@@ -13,6 +13,7 @@ import { ZSendVerificationCodeInputSchema } from "./sendVerificationCode.schema"
|
||||
import { ZUpdateInputSchema } from "./update.schema";
|
||||
import { ZVerifyEmailCodeInputSchema } from "./verifyEmailCode.schema";
|
||||
import { ZVerifyPhoneNumberInputSchema } from "./verifyPhoneNumber.schema";
|
||||
import { ZWorkflowOrderInputSchema } from "./workflowOrder.schema";
|
||||
|
||||
type WorkflowsRouterHandlerCache = {
|
||||
list?: typeof import("./list.handler").listHandler;
|
||||
@@ -29,6 +30,7 @@ type WorkflowsRouterHandlerCache = {
|
||||
getVerifiedEmails?: typeof import("./getVerifiedEmails.handler").getVerifiedEmailsHandler;
|
||||
verifyEmailCode?: typeof import("./verifyEmailCode.handler").verifyEmailCodeHandler;
|
||||
getAllActiveWorkflows?: typeof import("./getAllActiveWorkflows.handler").getAllActiveWorkflowsHandler;
|
||||
workflowOrder?: typeof import("./workflowOrder.handler").workflowOrderHandler;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: WorkflowsRouterHandlerCache = {};
|
||||
@@ -276,4 +278,16 @@ export const workflowsRouter = router({
|
||||
input,
|
||||
});
|
||||
}),
|
||||
workflowOrder: authedProcedure.input(ZWorkflowOrderInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.workflowOrder) {
|
||||
UNSTABLE_HANDLER_CACHE.workflowOrder = (await import("./workflowOrder.handler")).workflowOrderHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.workflowOrder) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.workflowOrder({ ctx, input });
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user