Skip to content

Commit 825f55c

Browse files
fix: extract shared types to non-React modules to fix circular dependencies (calcom#26083)
- Move InvalidAppCredentialBannerProps to packages/features/users/types/invalidAppCredentials.ts - Add WorkflowListType to packages/features/ee/workflows/lib/types.ts - Update server file imports to use new type locations - Update React component imports to re-export from new locations This fixes circular dependencies where server files were importing from React component modules that import from @calcom/trpc, creating: server -> component -> @calcom/trpc -> react -> server (circular) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 9ae2381 commit 825f55c

6 files changed

Lines changed: 49 additions & 43 deletions

File tree

packages/features/ee/workflows/components/WorkflowListPage.tsx

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import Link from "next/link";
33
import { useRouter } from "next/navigation";
44
import { useState } from "react";
55

6-
import type { WorkflowPermissions } from "@calcom/features/workflows/repositories/WorkflowPermissionsRepository";
76
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
87
import { useLocale } from "@calcom/lib/hooks/useLocale";
9-
import type { Membership, Workflow } from "@calcom/prisma/client";
108
import { trpc } from "@calcom/trpc/react";
119
import classNames from "@calcom/ui/classNames";
1210
import { ArrowButton } from "@calcom/ui/components/arrow-button";
@@ -25,38 +23,12 @@ import { Icon } from "@calcom/ui/components/icon";
2523
import { Tooltip } from "@calcom/ui/components/tooltip";
2624

2725
import { getActionIcon } from "../lib/getActionIcon";
28-
import type { WorkflowStep } from "../lib/types";
26+
import { type WorkflowListType } from "../lib/types";
2927
import { DeleteDialog } from "./DeleteDialog";
3028

31-
export type WorkflowType = Workflow & {
32-
team: {
33-
id: number;
34-
name: string;
35-
members: Membership[];
36-
slug: string | null;
37-
logo?: string | null;
38-
} | null;
39-
steps: WorkflowStep[];
40-
activeOnTeams?: {
41-
team: {
42-
id: number;
43-
name?: string | null;
44-
};
45-
}[];
46-
activeOn?: {
47-
eventType: {
48-
id: number;
49-
title: string;
50-
parentId: number | null;
51-
_count: {
52-
children: number;
53-
};
54-
};
55-
}[];
56-
readOnly?: boolean; // Keep for backward compatibility
57-
permissions?: WorkflowPermissions;
58-
isOrg?: boolean;
59-
};
29+
/** @deprecated Use WorkflowListType from ../lib/types instead */
30+
export type WorkflowType = WorkflowListType;
31+
6032
interface Props {
6133
workflows: WorkflowType[] | undefined;
6234
}

packages/features/ee/workflows/lib/types.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { FORM_SUBMITTED_WEBHOOK_RESPONSES } from "@calcom/app-store/routing-forms/lib/formSubmissionUtils";
2+
import type { WorkflowPermissions } from "@calcom/features/workflows/repositories/WorkflowPermissionsRepository";
23
import type { TimeFormat } from "@calcom/lib/timeFormat";
3-
import type { Prisma } from "@calcom/prisma/client";
4+
import type { Membership, Prisma, Workflow as PrismaWorkflow } from "@calcom/prisma/client";
45
import type { TimeUnit, WorkflowTemplates, WorkflowTriggerEvents } from "@calcom/prisma/enums";
56
import { WorkflowActions } from "@calcom/prisma/enums";
67
import type { CalEventResponses, RecurringEvent } from "@calcom/types/Calendar";
@@ -93,3 +94,33 @@ export type ScheduleEmailReminderAction = Extract<
9394
WorkflowActions,
9495
"EMAIL_HOST" | "EMAIL_ATTENDEE" | "EMAIL_ADDRESS"
9596
>;
97+
98+
export type WorkflowListType = PrismaWorkflow & {
99+
team: {
100+
id: number;
101+
name: string;
102+
members: Membership[];
103+
slug: string | null;
104+
logo?: string | null;
105+
} | null;
106+
steps: WorkflowStep[];
107+
activeOnTeams?: {
108+
team: {
109+
id: number;
110+
name?: string | null;
111+
};
112+
}[];
113+
activeOn?: {
114+
eventType: {
115+
id: number;
116+
title: string;
117+
parentId: number | null;
118+
_count: {
119+
children: number;
120+
};
121+
};
122+
}[];
123+
readOnly?: boolean;
124+
permissions?: WorkflowPermissions;
125+
isOrg?: boolean;
126+
};

packages/features/users/components/InvalidAppCredentialsBanner.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
44
import { type RouterOutputs } from "@calcom/trpc";
55
import { TopBanner } from "@calcom/ui/components/top-banner";
66

7+
import { type InvalidAppCredentialBannerProps } from "../types/invalidAppCredentials";
8+
79
export type InvalidAppCredentialBannersProps = {
810
data: RouterOutputs["viewer"]["me"]["getUserTopBanners"]["invalidAppCredentialBanners"];
911
};
@@ -22,10 +24,7 @@ export function InvalidAppCredentialBanners({ data }: InvalidAppCredentialBanner
2224
);
2325
}
2426

25-
export type InvalidAppCredentialBannerProps = {
26-
name: string;
27-
slug: string;
28-
};
27+
export type { InvalidAppCredentialBannerProps };
2928

3029
export function InvalidAppCredentialBanner({ name, slug }: InvalidAppCredentialBannerProps) {
3130
const { t } = useLocale();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type InvalidAppCredentialBannerProps = {
2+
name: string;
3+
slug: string;
4+
};

packages/trpc/server/routers/viewer/me/checkForInvalidAppCredentials.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getAppFromSlug } from "@calcom/app-store/utils";
2-
import { type InvalidAppCredentialBannerProps } from "@calcom/features/users/components/InvalidAppCredentialsBanner";
2+
import { type InvalidAppCredentialBannerProps } from "@calcom/features/users/types/invalidAppCredentials";
33
import { prisma } from "@calcom/prisma";
44
import { MembershipRole } from "@calcom/prisma/enums";
55
import type { TrpcSessionUser } from "@calcom/trpc/server/types";

packages/trpc/server/routers/viewer/workflows/list.handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
2-
import type { WorkflowType } from "@calcom/features/ee/workflows/components/WorkflowListPage";
2+
import type { WorkflowListType } from "@calcom/features/ee/workflows/lib/types";
33
import { WorkflowRepository } from "@calcom/features/ee/workflows/repositories/WorkflowRepository";
44
// import dayjs from "@calcom/dayjs";
55
// import { getErrorFromUnknown } from "@calcom/lib/errors";
@@ -19,7 +19,7 @@ type ListOptions = {
1919
};
2020

2121
export const listHandler = async ({ ctx, input }: ListOptions) => {
22-
const workflows: WorkflowType[] = [];
22+
const workflows: WorkflowListType[] = [];
2323
const teamRepository = new TeamRepository(ctx.prisma);
2424

2525
const org = await teamRepository.findOrganization({
@@ -42,7 +42,7 @@ export const listHandler = async ({ ctx, input }: ListOptions) => {
4242
}
4343

4444
if (input && input.teamId) {
45-
const teamWorkflows: WorkflowType[] = await WorkflowRepository.findTeamWorkflows({
45+
const teamWorkflows: WorkflowListType[] = await WorkflowRepository.findTeamWorkflows({
4646
teamId: input.teamId,
4747
userId: ctx.user.id,
4848
excludeFormTriggers: input.includeOnlyEventTypeWorkflows,
@@ -66,7 +66,7 @@ export const listHandler = async ({ ctx, input }: ListOptions) => {
6666
}
6767

6868
if (input && input.userId) {
69-
const userWorkflows: WorkflowType[] = await WorkflowRepository.findUserWorkflows({
69+
const userWorkflows: WorkflowListType[] = await WorkflowRepository.findUserWorkflows({
7070
userId: ctx.user.id,
7171
excludeFormTriggers: input.includeOnlyEventTypeWorkflows,
7272
});
@@ -87,7 +87,7 @@ export const listHandler = async ({ ctx, input }: ListOptions) => {
8787
excludeFormTriggers: input.includeOnlyEventTypeWorkflows,
8888
});
8989

90-
const workflowsWithReadOnly: WorkflowType[] = allWorkflows.map((workflow) => {
90+
const workflowsWithReadOnly: WorkflowListType[] = allWorkflows.map((workflow) => {
9191
const readOnly = !!workflow.team?.members?.find(
9292
(member) => member.userId === ctx.user.id && member.role === MembershipRole.MEMBER
9393
);

0 commit comments

Comments
 (0)