Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cerbos/orm-prisma

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cerbos/orm-prisma - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

10

package.json
{
"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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc