0.1.5 • Published 3 months ago

@styra/ucast-prisma v0.1.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

@styra/ucast-prisma

License NPM Version

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 Enterprise OPA 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 Styra products, services and open source projects, please join the Styra community on Slack!

0.1.0

4 months ago

0.1.2

4 months ago

0.1.1

4 months ago

0.1.4

3 months ago

0.1.3

3 months ago

0.1.5

3 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

7 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

9 months ago

0.0.1

9 months ago