fix: add explicit type annotation to CalComAdapter function (#22230)
* fix: add explicit type annotation to CalComAdapter function Resolves TS7056 error where inferred type exceeded maximum length the compiler will serialize. Added custom CalComAdapterType type annotation to provide explicit typing while preserving existing functionality of the authentication adapter. The custom type annotation matches the actual implementation structure and resolves the TypeScript compilation error without breaking the existing NextAuth adapter functionality. Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: replace any types with proper NextAuth Adapter typing - Import Awaitable type from next-auth for proper async typing - Define CalComAdapter type using Cal.com's actual Prisma types - Remove all any types following TypeScript best practices - Maintain compatibility with NextAuth's expected interface - Resolves TS7056 compilation error with explicit typing Co-Authored-By: alex@cal.com <me@alexvanandel.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: alex@cal.com <me@alexvanandel.com>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
alex@cal.com <me@alexvanandel.com>
parent
d04c7f58a1
commit
d23d68bf2d
@@ -1,12 +1,33 @@
|
||||
import type { Account, IdentityProvider, Prisma, User, VerificationToken } from "@prisma/client";
|
||||
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
|
||||
import type { Awaitable } from "next-auth";
|
||||
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
import { identityProviderNameMap } from "./identityProviderNameMap";
|
||||
|
||||
type CalComAdapter = {
|
||||
createUser: (data: Prisma.UserCreateInput) => Awaitable<User>;
|
||||
getUser: (id: string | number) => Awaitable<User | null>;
|
||||
getUserByEmail: (email: User["email"]) => Awaitable<User | null>;
|
||||
getUserByAccount: (provider_providerAccountId: {
|
||||
providerAccountId: Account["providerAccountId"];
|
||||
provider: User["identityProvider"];
|
||||
}) => Awaitable<User | null>;
|
||||
updateUser: (data: Prisma.UserUncheckedCreateInput) => Awaitable<User>;
|
||||
deleteUser: (id: User["id"]) => Awaitable<User>;
|
||||
createVerificationToken: (data: VerificationToken) => Awaitable<Omit<VerificationToken, "id">>;
|
||||
useVerificationToken: (
|
||||
identifier_token: Prisma.VerificationTokenIdentifierTokenCompoundUniqueInput
|
||||
) => Awaitable<Omit<VerificationToken, "id"> | null>;
|
||||
linkAccount: (data: Prisma.AccountCreateInput) => Awaitable<Account>;
|
||||
unlinkAccount: (
|
||||
provider_providerAccountId: Prisma.AccountProviderProviderAccountIdCompoundUniqueInput
|
||||
) => Awaitable<Account>;
|
||||
};
|
||||
|
||||
/** @return { import("next-auth/adapters").Adapter } */
|
||||
export default function CalComAdapter(prismaClient: PrismaClient) {
|
||||
export default function CalComAdapter(prismaClient: PrismaClient): CalComAdapter {
|
||||
return {
|
||||
createUser: (data: Prisma.UserCreateInput) => prismaClient.user.create({ data }),
|
||||
getUser: (id: string | number) =>
|
||||
|
||||
Reference in New Issue
Block a user