@cerbos/orm-prisma
Version:
Prisma adapter for Cerbos query plans
28 lines • 897 B
TypeScript
import { PlanResourcesResponse, PlanKind } from "@cerbos/core";
export { PlanKind };
export type PrismaFilter = Record<string, any>;
export type MapperConfig = {
field?: string;
relation?: {
name: string;
type: "one" | "many";
field?: string;
fields?: Record<string, MapperConfig>;
};
};
export type Mapper = Record<string, MapperConfig> | ((key: string) => MapperConfig);
export interface QueryPlanToPrismaArgs {
queryPlan: PlanResourcesResponse;
mapper?: Mapper;
}
export type QueryPlanToPrismaResult = {
kind: PlanKind.ALWAYS_ALLOWED | PlanKind.ALWAYS_DENIED;
} | {
kind: PlanKind.CONDITIONAL;
filters: PrismaFilter;
};
/**
* Converts a Cerbos query plan to a Prisma filter.
*/
export declare function queryPlanToPrisma({ queryPlan, mapper, }: QueryPlanToPrismaArgs): QueryPlanToPrismaResult;
//# sourceMappingURL=index.d.ts.map