refactor: circular deps between app store and lib [6] (#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
This commit is contained in:
Benny Joo authored and GitHub committed 2025-10-09 14:02:12 +00:00
1 parent 445b307972
commit bb68cd73ef
114 files changed
+263 -245

No files matched your search

@@ -1,28 +0,0 @@
import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server";
import { availabilityUserSelect } from "@calcom/prisma";
import { prisma } from "@calcom/prisma";
import type { Prisma } from "@calcom/prisma/client";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import { withSelectedCalendars } from "./withSelectedCalendars";
export async function findUsersForAvailabilityCheck({ where }: { where: Prisma.UserWhereInput }) {
const user = await prisma.user.findFirst({
where,
select: {
...availabilityUserSelect,
selectedCalendars: true,
credentials: {
select: credentialForCalendarServiceSelect,
},
},
});
if (!user) {
return null;
}
return await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
user: withSelectedCalendars(user),
});
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,36 +0,0 @@
import { prisma } from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "../delegationCredential/server";
type User = { id: number; email: string };
/**
* It includes in-memory DelegationCredential credentials as well.
*/
export async function getUsersCredentialsIncludeServiceAccountKey(user: User) {
const credentials = await prisma.credential.findMany({
where: {
userId: user.id,
},
select: credentialForCalendarServiceSelect,
orderBy: {
id: "asc",
},
});
const { credentials: allCredentials } = await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
user: {
email: user.email,
id: user.id,
credentials,
},
});
return allCredentials;
}
export async function getUsersCredentials(user: User) {
const credentials = await getUsersCredentialsIncludeServiceAccountKey(user);
return credentials.map(({ delegatedTo: _1, ...rest }) => rest);
}
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Prisma, PrismaClient } from "@calcom/prisma/client";
import { safeCredentialSelect } from "@calcom/prisma/selects/credential";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
import { buildNonDelegationCredential } from "../../delegationCredential/server";
import { buildNonDelegationCredential } from "../../delegationCredential";
const log = logger.getSubLogger({ prefix: ["CredentialRepository"] });
+1 -1
View File
@@ -1,6 +1,7 @@
import type { z } from "zod";
import { whereClauseForOrgWithSlugOrRequestedSlug } from "@calcom/ee/organizations/lib/orgDomains";
import { buildNonDelegationCredentials } from "@calcom/lib/delegationCredential";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { getTranslation } from "@calcom/lib/server/i18n";
@@ -15,7 +16,6 @@ import { userMetadata } from "@calcom/prisma/zod-utils";
import type { UpId, UserProfile } from "@calcom/types/UserProfile";
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "../../availability";
import { buildNonDelegationCredentials } from "../../delegationCredential/clientAndServer";
import { withSelectedCalendars } from "../withSelectedCalendars";
import { ProfileRepository } from "./profile";
import { getParsedTeam } from "./teamUtils";