I'm currently working on an API that utilizes Prisma to provide data. This API is used in various projects. Within the API, I create types using Prisma.ModelGetPayload
to specify the return types for certain API responses.
import { Prisma } from "@prisma/client";
export const minimalSelect = Prisma.validator<Prisma.ModelXYSelect>()({
id: true,
name: true
});
export type MinimalModelXY = Prisma.ModelXYGetPayload<{
select: typeof minimalSelect;
}>;
Alternatively, enums can be directly imported from the Prisma client.
import { EnumXY } from "@prisma/client";
These enums and type definitions are dependent on the generated Prisma client of the API.
While there are options to extract the entire Prisma client into an npm package (refer here), this approach may not align with my preferences.
Is there a way to extract these types into an npm package in order to share them across multiple projects without extracting the entire Prisma client?