@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/README.md +196 -101
- package/lib/cjs/index.d.ts +26 -19
- package/lib/cjs/index.js +492 -144
- package/lib/index.d.ts +26 -19
- package/lib/index.js +487 -139
- package/package.json +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import { PlanResourcesResponse, PlanKind
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
[key: string]:
|
|
13
|
-
} | ((key: string) =>
|
|
14
|
-
interface QueryPlanToPrismaArgs {
|
|
15
|
+
export type Mapper = {
|
|
16
|
+
[key: string]: MapperConfig;
|
|
17
|
+
} | ((key: string) => MapperConfig);
|
|
18
|
+
export interface QueryPlanToPrismaArgs {
|
|
15
19
|
queryPlan: PlanResourcesResponse;
|
|
16
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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;
|