Skip to content

Commit bb68cd7

Browse files
authored
refactor: circular deps between app store and lib [6] (calcom#23971)
* move delegation credential repository to features * mv credential repository to features * update imports * mv * fix * fix * fix * fix * fix * update imports * update imports * update eslint rule * fix * fix * mv getConnectedDestinationCalendars * fix import errors * mv getCalendarsEvents * remove getUsersCredentials * wip * revert eslint rule change for now * fix type checks * fix * format * cleanup * fix * fix * fix * fix * fix tests * migrate getUserAvailability * migrate * fix tests * fix type checks * fix * fix * migrate crmManager * update imports * migrate raqbUtils to appstore * migrate getLuckyUser to features * migrate findTeamMembersMatchingAttributeLogic to appstore * update imports * fix * fix * fix test * fix unit tests * fix * fix * add eslint config
1 parent 445b307 commit bb68cd7

114 files changed

Lines changed: 259 additions & 241 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/api/v1/pages/api/connected-calendars/_get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NextApiRequest } from "next";
22

3-
import type { UserWithCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
4-
import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars";
3+
import type { UserWithCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
4+
import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
55
import { HttpError } from "@calcom/lib/http-error";
66
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
77
import { UserRepository } from "@calcom/lib/server/repository/user";

apps/web/app/(use-page-wrapper)/apps/routing-forms/[...pages]/RouteBuilder.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { UseFormReturn } from "react-hook-form";
1010
import { Toaster } from "sonner";
1111
import type { z } from "zod";
1212

13+
import { buildEmptyQueryValue, raqbQueryValueUtils } from "@calcom/app-store/_utils/raqb/raqbUtils";
1314
import { routingFormAppComponents } from "@calcom/app-store/routing-forms/appComponents";
1415
import DynamicAppComponent from "@calcom/app-store/routing-forms/components/DynamicAppComponent";
1516
import { EmptyState } from "@calcom/app-store/routing-forms/components/_components/EmptyState";
@@ -44,7 +45,6 @@ import { useOrgBranding } from "@calcom/features/ee/organizations/context/provid
4445
import type { EventTypesByViewer } from "@calcom/features/eventtypes/lib/getEventTypesByViewer";
4546
import { areTheySiblingEntities } from "@calcom/lib/entityPermissionUtils.shared";
4647
import { useLocale } from "@calcom/lib/hooks/useLocale";
47-
import { buildEmptyQueryValue, raqbQueryValueUtils } from "@calcom/lib/raqb/raqbUtils";
4848
import type { Prisma } from "@calcom/prisma/client";
4949
import { SchedulingType } from "@calcom/prisma/enums";
5050
import { trpc } from "@calcom/trpc/react";
@@ -1190,7 +1190,7 @@ const Routes = ({
11901190
}) || [];
11911191

11921192
// const isConnectedForm = (id: string) => form.connectedForms.map((f) => f.id).includes(id);
1193-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1193+
11941194
// const routers: any[] = [];
11951195
/* Disable this feature for new forms till we get it fully working with Routing Form with Attributes. This isn't much used feature */
11961196
// const routers = availableRouters.map((r) => {
@@ -1235,15 +1235,15 @@ const Routes = ({
12351235
});
12361236
setRoutes((routes) => {
12371237
// Even though it's obvious that fallbackRoute is defined here but TypeScript just can't figure it out.
1238-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1238+
12391239
return [...routes, fallbackRoute!];
12401240
});
12411241
return null;
12421242
} else if (routes.indexOf(fallbackRoute) !== routes.length - 1) {
12431243
// Ensure fallback is last
12441244
setRoutes((routes) => {
12451245
// Even though it's obvious that fallbackRoute is defined here but TypeScript just can't figure it out.
1246-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1246+
12471247
return [...routes.filter((route) => route.id !== fallbackRoute!.id), fallbackRoute!];
12481248
});
12491249
}

apps/web/app/api/cron/selected-calendars/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { NextResponse } from "next/server";
88

99
import GoogleCalendarService from "@calcom/app-store/googlecalendar/lib/CalendarService";
1010
import { CalendarAppDelegationCredentialInvalidGrantError } from "@calcom/lib/CalendarAppError";
11-
import { findUniqueDelegationCalendarCredential } from "@calcom/lib/delegationCredential/server";
11+
import { findUniqueDelegationCalendarCredential } from "@calcom/app-store/delegationCredential";
1212
import { HttpError } from "@calcom/lib/http-error";
1313
import logger from "@calcom/lib/logger";
1414
import { safeStringify } from "@calcom/lib/safeStringify";

packages/app-store/_appRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
22
import { getAppFromSlug } from "@calcom/app-store/utils";
3+
import { getAllDelegationCredentialsForUser } from "@calcom/app-store/delegationCredential";
34
import getInstallCountPerApp from "@calcom/lib/apps/getInstallCountPerApp";
4-
import { getAllDelegationCredentialsForUser } from "@calcom/lib/delegationCredential/server";
55
import type { UserAdminTeams } from "@calcom/lib/server/repository/user";
66
import prisma, { safeAppSelect, safeCredentialSelect } from "@calcom/prisma";
77
import { userMetadata } from "@calcom/prisma/zod-utils";

packages/app-store/_utils/CRMRoundRobinSkip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { z } from "zod";
22

33
import type { EventTypeAppMetadataSchema } from "@calcom/app-store/zod-utils";
4-
import CrmManager from "@calcom/lib/crmManager/crmManager";
4+
import CrmManager from "@calcom/features/crmManager/crmManager";
55
import logger from "@calcom/lib/logger";
66
import { prisma } from "@calcom/prisma";
77
import type { Prisma } from "@calcom/prisma/client";

packages/app-store/_utils/getConnectedApps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential";
12
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
23
import getInstallCountPerApp from "@calcom/lib/apps/getInstallCountPerApp";
3-
import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential/clientAndServer";
4-
import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials";
4+
import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential";
55
import type { PrismaClient } from "@calcom/prisma";
66
import type { Prisma, User, AppCategories } from "@calcom/prisma/client";
77
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";

packages/app-store/_utils/getDefaultLocations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { z } from "zod";
22

3-
import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/lib/server/getUsersCredentials";
3+
import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential";
44
import type { Prisma } from "@calcom/prisma/client";
55
import { userMetadata as userMetadataSchema, type eventTypeLocations } from "@calcom/prisma/zod-utils";
66

packages/app-store/_utils/getEnabledAppsFromCredentials.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CredentialDataWithTeamName } from "@calcom/app-store/utils";
2-
import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
2+
import { isDelegationCredential } from "@calcom/lib/delegationCredential";
33
import { prisma } from "@calcom/prisma";
44
import type { Prisma } from "@calcom/prisma/client";
55

packages/app-store/_utils/oauth/getCurrentTokenObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isInMemoryDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
1+
import { isInMemoryDelegationCredential } from "@calcom/lib/delegationCredential";
22
import logger from "@calcom/lib/logger";
33
import { CredentialRepository } from "@calcom/lib/server/repository/credential";
44
import type { CredentialForCalendarService } from "@calcom/types/Credential";

packages/lib/raqb/findTeamMembersMatchingAttributeLogic.test.ts renamed to packages/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { RaqbLogicResult } from "@calcom/lib/raqb/evaluateRaqbLogic";
66
import {
77
findTeamMembersMatchingAttributeLogic,
88
TroubleshooterCase,
9-
} from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic";
9+
} from "@calcom/app-store/_utils/raqb/findTeamMembersMatchingAttributeLogic";
1010
import * as getAttributesModule from "@calcom/lib/service/attribute/server/getAttributes";
1111
import type { AttributeType } from "@calcom/prisma/enums";
1212
import { RoutingFormFieldType } from "@calcom/routing-forms/lib/FieldTypes";
@@ -18,7 +18,7 @@ vi.mock("@calcom/lib/service/attribute/server/getAttributes", () => {
1818
};
1919
});
2020

21-
vi.mock("../../components/react-awesome-query-builder/widgets", () => ({
21+
vi.mock("@calcom/app-store/routing-forms/components/react-awesome-query-builder/widgets", () => ({
2222
default: {},
2323
}));
2424

@@ -64,13 +64,13 @@ function mockAttributesScenario({
6464
Object.entries(member.attributes).map(([attributeId, value]) => {
6565
return [
6666
attributeId,
67-
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
67+
6868
{
6969
attributeOption:
7070
value instanceof Array
7171
? value.map((value) => ({ value, isGroup: false, contains: [] }))
7272
: { value, isGroup: false, contains: [] },
73-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
73+
7474
type: attributes.find((attribute) => attribute.id === attributeId)!.type,
7575
},
7676
];

0 commit comments

Comments
 (0)