open-index/open-npm huggingface dataset:
npm package: @styra/highlightjs-rego
Description: Rego policy language syntax highlighting plugin for highlight.js
Author: Anders Eknert
Latest version: 0.1.2

# highlightjs-rego

[highlight.js](https://highlightjs.org/) syntax highlighting for the
[Rego](https://www.openpolicyagent.org/docs/latest/policy-language) language of Open Policy Agent (OPA).

![Screenshot](assets/highlight-rego.png)

## How to use

Head over to the [releases](https://github.com/StyraInc/highlightjs-rego/releases) page and grab the minified version of
the Rego syntax definition file (`rego.min.js` or `rego.es.min.js`). Include it in your HTML file, and use the
`language-rego` class for the `<code>` block you want to highlight:

```html
<!DOCTYPE html>
<html>
<head>
  <title>Highlight.js Rego Demo</title>
  <link rel="stylesheet" href="path/to/theme.css">
  <script type="text/javascript" src="path/to/highlight.min.js"></script>
  <script type="text/javascript" src="path/to/rego.min.js"></script>
  <script type="text/javascript">hljs.highlightAll();</script>
</head>

<body>
  <pre><code class="language-rego">
# METADATA
# description: Your Rego policy here!
package policy

default allow := false

allow if {
    # ..conditions..
}
  </code></pre>
</body>

</html>
```

## How to build

Building from source can either be done by running the `build.sh` script in this repository, or manually
following the steps below.

1. Clone the highlight.js repository
   ```
   git clone https://github.com/highlightjs/highlight.js.git
   ```
2. Clone this repository
    ```
    git clone https://github.com/StyraInc/highlightjs-rego.git
    ```
3. In the `extra` directory of the highlight.js repository, create a symlink to this repository
    ```shell
    ln -s /path/to/highlightjs-rego /path/to/highlight.js/extra/highlightjs-rego
    ```
4. In the root of the highlight.js repository, run:
   ```shell
   node ./tools/build.js -t cdn
   ```
5. You'll now find `rego.min.js` in the `build` directory

More detailed instructions for building 3rd party language support for highlight.js can be found
[here](https://github.com/highlightjs/highlight.js/blob/main/extra/3RD_PARTY_QUICK_START.md#packaging).

## Community

For questions, discussions and announcements related to Styra products, services and open source projects, please join
the Styra community on [Slack](https://communityinviter.com/apps/styracommunity/signup)!
npm package: @styra/opa-react
Description: Styra-supported React hooks and components for frontend authorization based on @styra/opa
Author: Styra Inc.
Latest version: 0.7.0

# @styra/opa-react

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![NPM Version](https://img.shields.io/npm/v/%40styra%2Fopa-react?style=flat&color=%2324b6e0)](https://www.npmjs.com/package/@styra/opa-react)

This package contains helpers for using [@styra/opa](https://www.npmjs.com/package/@styra/opa) from React.

## Features

* High-level, declarative components for embedding authorization decisions in your frontend code.
* Built-in caching, deduplication, and state management based on `@tanstack/react-query`.
* Optional **request batching** for backends that support it (Enterprise OPA, or your own implementation of the Batch API).

## Details

The package provides an `useAuthz` hook and a high-level `<Authz>` component.

They are enabled by wrapping your App into `<AuthzProvider>`:

```tsx
<AuthzProvider opaClient={opaClient} defaultPath="policy" defaultInput={{ user, tenant }}>
  <Nav />
  <Outlet />
</AuthzProvider>
```

This example provides a previously-configured `opaClient` instance (`OPAClient` from `@styra/opa`), a request path, and default input (which is merged with per-call inputs).

They can either be used by providing static children (`<button>Press Here</button>`) and optionally `fallback` and `loading` JSX elements:
```tsx
<Authz
  path={path}
  input={input}
  loading={<div>...</div>}
  fallback={<button disabled={true}>Press Here</button>}>
  <button>Press Here</button>
</Authz>
```

The `useAuthz` hook can be used if you need more low-level control about the authorization call.
Furthermore, you can retrieve the prepared `opaClient` instance of `AuthzProvider` for even more control, if need be:

```tsx
import { AuthzContext } from "@styra/opa-react";

export default function Component() {
  const { opaClient } = useContext(AuthzContext);
  // now you can use `opaClient.evaluate()` etc directly
}
```


## Community

For questions, discussions and announcements related to Styra products, services and open source projects, please join
the Styra community on [Slack](https://communityinviter.com/apps/styracommunity/signup)!
npm package: @styra/ucast-prisma
Description: Styra-supported interpreter for using ucast conditions with Prisma.
Author: Styra Inc.
Latest version: 0.1.5

# @styra/ucast-prisma

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![NPM Version](https://img.shields.io/npm/v/%40styra%2Fucast-prisma?style=flat&color=%2324b6e0)](https://www.npmjs.com/package/@styra/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 [Enterprise OPA Compile API](https://docs.styra.com/enterprise-opa/reference/api-reference/partial-evaluation-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": "<username>"
    }
  }
}
```

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.


## Community

For questions, discussions and announcements related to Styra products, services and open source projects, please join
the Styra community on [Slack](https://communityinviter.com/apps/styracommunity/signup)!