@cerbos/orm-prisma
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "@cerbos/orm-prisma", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"homepage": "https://cerbos.dev", | ||
@@ -28,10 +28,10 @@ "description": "", | ||
"prisma": "^4.3.1", | ||
"ts-jest": "^28.0.8", | ||
"ts-jest": "^29.0.0", | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.4" | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@cerbos/core": "^0.5.1", | ||
"@cerbos/grpc": "^0.8.0" | ||
"@cerbos/core": "^0.12.0", | ||
"@cerbos/grpc": "^0.12.0" | ||
} | ||
} |
# Cerbos + Prisma ORM Adapter | ||
An adapater library that takes a [Cerbos](https://cerbos.dev) Query Plan ([PlanResources API](https://docs.cerbos.dev/cerbos/latest/api/index.html#resources-query-plan)) response and converts it into a [Prisma](https://prisma.io) where class object. This is designed to work alongside a project using the [Cerbos Javascript SDK](https://github.com/cerbos/cerbos-sdk-javascript). | ||
An adapter library that takes a [Cerbos](https://cerbos.dev) Query Plan ([PlanResources API](https://docs.cerbos.dev/cerbos/latest/api/index.html#resources-query-plan)) response and converts it into a [Prisma](https://prisma.io) where class object. This is designed to work alongside a project using the [Cerbos Javascript SDK](https://github.com/cerbos/cerbos-sdk-javascript). | ||
@@ -21,2 +21,3 @@ The following conditions are supported: `and`, `or`, `eq`, `ne`, `lt`, `gt`, `lte`, `gte` and `in`, as well as relational filters `some`, `none`, `is` and `isNot`. | ||
## Requirements | ||
- Cerbos > v0.16 | ||
@@ -121,4 +122,4 @@ - `@cerbos/http` or `@cerbos/grpc` client | ||
fieldNameMapper: { | ||
"request.resource.attr.aFieldName": "prismaModelFieldName" | ||
} | ||
"request.resource.attr.aFieldName": "prismaModelFieldName", | ||
}, | ||
}); | ||
@@ -131,14 +132,13 @@ | ||
fieldNameMapper: (fieldName: string): string => { | ||
if(fieldName.indexOf("request.resource.") > 0) { | ||
return fieldName.replace("request.resource.attr", "") | ||
if (fieldName.indexOf("request.resource.") > 0) { | ||
return fieldName.replace("request.resource.attr", ""); | ||
} | ||
if(fieldName.indexOf("request.principal.") > 0) { | ||
return fieldName.replace("request.principal.attr", "") | ||
if (fieldName.indexOf("request.principal.") > 0) { | ||
return fieldName.replace("request.principal.attr", ""); | ||
} | ||
} | ||
}, | ||
}); | ||
``` | ||
The `relationMapper` is used to convert references to fields which are joins at the database level | ||
@@ -152,6 +152,6 @@ | ||
"request.resource.attr.aRelatedModel": { | ||
"relation": "aRelatedModel", | ||
"field": "id" // the column it is joined on | ||
} | ||
} | ||
relation: "aRelatedModel", | ||
field: "id", // the column it is joined on | ||
}, | ||
}, | ||
}); | ||
@@ -165,9 +165,9 @@ | ||
relationMapper: (fieldName: string): string => { | ||
if(fieldName.indexOf("request.resource.") > 0) { | ||
if (fieldName.indexOf("request.resource.") > 0) { | ||
return { | ||
"relation": fieldName.replace("request.resource.attr.", ""), | ||
"field": "id" // the column it is joined on | ||
} | ||
relation: fieldName.replace("request.resource.attr.", ""), | ||
field: "id", // the column it is joined on | ||
}; | ||
} | ||
} | ||
}, | ||
}); | ||
@@ -178,2 +178,2 @@ ``` | ||
A full Prisma application making use of this adapater can be found at [https://github.com/cerbos/express-prisma-cerbos](https://github.com/cerbos/express-prisma-cerbos) | ||
A full Prisma application making use of this adapater can be found at [https://github.com/cerbos/express-prisma-cerbos](https://github.com/cerbos/express-prisma-cerbos) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17314
174
+ Added@cerbos/core@0.12.0(transitive)
+ Added@cerbos/grpc@0.12.0(transitive)
- Removed@cerbos/core@0.5.10.8.1(transitive)
- Removed@cerbos/grpc@0.8.2(transitive)
- Removed@types/long@4.0.2(transitive)
- Removedlong@4.0.0(transitive)
- Removedprotobufjs@6.11.4(transitive)
- Removeduuid@8.3.2(transitive)
Updated@cerbos/core@^0.12.0
Updated@cerbos/grpc@^0.12.0