@cerbos/orm-prisma 1.1.1 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,24 +1,31 @@
1
- import { PlanResourcesResponse, PlanKind as PK } from "@cerbos/core";
2
- export declare type PlanKind = PK;
3
- export declare const PlanKind: typeof PK;
4
- declare type FieldMapper = {
5
- [key: string]: string;
6
- } | ((key: string) => string);
7
- declare type Relation = {
8
- relation: string;
9
- field: string;
1
+ import { PlanResourcesResponse, PlanKind } from "@cerbos/core";
2
+ export { PlanKind };
3
+ export type PrismaFilter = Record<string, any>;
4
+ export type MapperConfig = {
5
+ field?: string;
6
+ relation?: {
7
+ name: string;
8
+ type: "one" | "many";
9
+ field?: string;
10
+ fields?: {
11
+ [key: string]: MapperConfig;
12
+ };
13
+ };
10
14
  };
11
- declare type RelationMapper = {
12
- [key: string]: Relation;
13
- } | ((key: string) => Relation);
14
- interface QueryPlanToPrismaArgs {
15
+ export type Mapper = {
16
+ [key: string]: MapperConfig;
17
+ } | ((key: string) => MapperConfig);
18
+ export interface QueryPlanToPrismaArgs {
15
19
  queryPlan: PlanResourcesResponse;
16
- fieldNameMapper: FieldMapper;
17
- relationMapper?: RelationMapper;
20
+ mapper?: Mapper;
18
21
  }
19
- interface QueryPlanToPrismaResult {
22
+ export interface QueryPlanToPrismaResult {
20
23
  kind: PlanKind;
21
- filters?: any;
24
+ filters?: Record<string, any>;
22
25
  }
23
- export declare function queryPlanToPrisma({ queryPlan, fieldNameMapper, relationMapper, }: QueryPlanToPrismaArgs): QueryPlanToPrismaResult;
24
- export {};
26
+ /**
27
+ * Converts a Cerbos query plan to a Prisma filter.
28
+ * @param {QueryPlanToPrismaArgs} args - The arguments containing the query plan and mapper.
29
+ * @returns {QueryPlanToPrismaResult} The result containing the kind and filters.
30
+ */
31
+ export declare function queryPlanToPrisma({ queryPlan, mapper, }: QueryPlanToPrismaArgs): QueryPlanToPrismaResult;