@open-policy-agent/ucast-prisma
v0.1.6
Published
Interpreter for using ucast conditions with Prisma.
Readme
@open-policy-agent/ucast-prisma
This package contains helpers for using UCAST conditions with Prisma queries.
Usage
This package can be used to add filtering to Prisma queries from UCAST conditions. The conditions returned by the EOPA Compile API look like this:
{
"conditions": {
"or": [
{ "tickets.resolved": false },
{ "users.name": "ceasar" }
]
}
}A call to ucastToPrisma(conditions, "tickets") turns it into this
Prisma query:
{
"OR": [
{
"resolved": {
"equals": false
}
},
{
"users": {
"name": {
"equals": "ceasar"
}
}
}
]
}A similar translation for masking rules is provided through the mask helper:
E.g. the mask rules returned from the Compile API,
{
"tickets.assignee": {
"replace": {
"value": "***"
}
},
"users.name": {
"replace": {
"value": "<username>"
}
}
}can be applied to a Prisma-returned object like
{
"id": 200,
"assignee": "bob",
"users": {
"id": 10,
"name": "bobby"
}
}via mask(maskRules, obj, "tickets"), masking the appropriate fields.
Community
For questions, discussions and announcements related to this project, please join Slack!
