PrismaP
Prisma5mo ago
5 replies
Vinicius Gonçalves

Export extended Prisma client types

Greetings,

I'm trying to export an extended Prisma client types from a library package that is meant to be use through multiple NestJS applications.

This package contains:

- Prisma schema
- postinstall script to generate the prisma client and build the src/client.ts file with the extended client source code.

Code:

// @org/database
import { PrismaClient } from '#client';
import { softDeleteExtension } from '#extensions/soft-delete.js';

type ExtendedPrismaClient = ReturnType<typeof generatePrismaClient>;
type ExtendedPrismaClientOptions = ConstructorParameters<typeof PrismaClient>[0];

function generatePrismaClient(args: SoulloopPrismaClientOptions) {
  return new PrismaClient(args).$extends(softDeleteExtension);
}

export * from '#client';
export { generatePrismaClient };
export type { SoulloopPrismaClient, SoulloopPrismaClientOptions };


// @org/api-1: ./src/prisma/prisma.provider.ts
import type { SoulloopPrismaClientOptions } from '@org/database'

const Options: SoulloopPrismaClientOptions // resolves to any
Was this page helpful?