- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 126
Closed
Labels
Milestone
Description
Description and expected behavior
When using client extensions, the type gets thrown off with auth() in @default
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- ZenStack version: 2.1.0
- Prisma version: 5.13
- Database type: Postgres
Additional context
https://discord.com/channels/1035538056146595961/1245476523595534337/1245476523595534337
Code
import crypto from "node:crypto";
import { PrismaClient } from "@prisma/client";
import { enhance } from "@zenstackhq/runtime";
const prismaClientSingleton = () => {
    return new PrismaClient().$extends({
        result: {
            user: {
                gravatarUrl: {
                    needs: { email: true },
                    compute(user) {
                        const hash = crypto.createHash("md5");
                        hash.update(user.email);
                        return `https://www.gravatar.com/avatar/${hash.digest("hex")}`;
                    },
                },
            },
        },
    });
};
// biome-ignore lint/suspicious/noShadowRestrictedNames: used for dev mode
declare const globalThis: {
    prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;
export const _prisma = globalThis.prismaGlobal ?? prismaClientSingleton();
if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = _prisma;
export const dbAdmin = enhance(_prisma, undefined, { kinds: [] });
_prisma.user.findFirst().then((user) => user?.gravatarUrl);
dbAdmin.user.findFirst().then((user) => user?.gravatarUrl);