Styra-supported interpreter for using ucast conditions with Prisma.
npm install @styra/ucast-prisma

This package contains helpers for using UCAST conditions with Prisma queries.
This package can be used to add filtering to Prisma queries from UCAST conditions.
The conditions returned by the Enterprise OPA Compile API
look like this:
``json`
{
"conditions": {
"or": [
{ "tickets.resolved": false },
{ "users.name": "ceasar" }
]
}
}
A call to ucastToPrisma(conditions, "tickets") turns it into this
Prisma query:
`json`
{
"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,
`json`
{
"tickets.assignee": {
"replace": {
"value": "*"
}
},
"users.name": {
"replace": {
"value": "
}
}
}
can be applied to a Prisma-returned object like
`json`
{
"id": 200,
"assignee": "bob",
"users": {
"id": 10,
"name": "bobby"
}
}
via mask(maskRules, obj, "tickets")`, masking the appropriate fields.
For questions, discussions and announcements related to Styra products, services and open source projects, please join
the Styra community on Slack!