1.2.0-33e1256 • Published 11 months ago

@zregvart/opa-inspect v1.2.0-33e1256

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

opa inspect for JavaScript

This compiles the functionality of opa inspect wrapped in JavaScript by inspect.go to WebAssembly, which is included in main.js with the Go runtime from wasm_exec.js -- included in the Golang runtime and copied to the package.

Example

Add the dependency:

npm add @zregvart/opa-inspect

Run this example with node example.js

import * as opa from "@zregvart/opa-inspect";

opa.inspect(
    "example.rego",
    `package example

# METADATA
# title: Task bundle was not used or is not defined
# description: |-
#   Check for existence of a task bundle. Enforcing this rule will
#   fail the contract if the task is not called from a bundle.
# custom:
#   short_name: disallowed_task_reference
#   failure_msg: Task '%s' does not contain a bundle reference
#
deny[msg] {
    msg := "nope"
}`).then(json => {
  console.log(json);
});

Running examples

In browser example

Run the dev script with the examples/browser workspace, for example:

$ npm run -w examples/browser dev

  VITE v4.1.1  ready in 166 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

And open http://localhost:5173/ in the browser.

API

opa.inspect

Can be called with following combination of arguments:

  • <string> - a path that can be read using the fs module
  • <string>, <string> - a path/filename and the content of the Rego module inline, performs in-memory
  • <Array<string>> - an array of paths that can be read using the fs module
  • <stream<File>> - a Vinyl stream of files
  • `<Array> - an array of Vinyl files

Building

Run make build to build, this copies wasm_exec.js from the Golang runtime and compiles inspect.go to WebAssembly.

Demo

Run make demo to build and run the example in example.js

1.2.0-33e1256

11 months ago

1.2.0-cc03b5a

11 months ago

1.2.0-aad994a

11 months ago

1.1.0-3f25e7c

11 months ago

1.1.0-32a2623

11 months ago

1.1.0-b11c08e

12 months ago

1.1.0-4f1faef

12 months ago

1.1.0-2032c9e

1 year ago

0.70.0-13d54ca

1 year ago

0.70.0-27a8412

1 year ago

0.70.0-3a3d2f0

1 year ago

0.70.0-5704ad6

1 year ago

0.70.0-0a0b822

1 year ago

0.70.0-8ea31fb

1 year ago

0.70.0-f59869e

1 year ago

0.70.0-274f6e2

1 year ago

0.69.0-cd3637a

1 year ago

0.69.0-baebade

1 year ago

0.69.0-45bcc7d

1 year ago

0.68.0-458c1b3

1 year ago

0.68.0-01e9039

1 year ago

0.68.0-689e1f0

1 year ago

0.67.1-f1256b4

1 year ago

0.67.1-3e2de6a

1 year ago

0.67.1-78e3243

1 year ago

0.67.1-2553ad1

1 year ago

0.67.0-161abc4

2 years ago

0.67.0-940db41

2 years ago

0.66.0-a14db5c

2 years ago

0.66.0-9885b5e

2 years ago

0.66.0-64635db

2 years ago

0.65.0-ce2913c

2 years ago

0.65.0-bf25ff8

2 years ago

0.65.0-f597552

2 years ago

0.64.1-6cfc645

2 years ago

0.65.0-9c1aea0

2 years ago

0.64.1-9105c0c

2 years ago

0.64.1-f04a36e

2 years ago

0.64.0-bf937a0

2 years ago

0.63.0-e1d389f

2 years ago

0.63.0-c06e261

2 years ago

0.63.0-e1d3dbc

2 years ago

0.62.1-62ac029

2 years ago

0.62.1-a1f5c5e

2 years ago

0.62.1-a35cebc

2 years ago

0.62.1-c41bcd8

2 years ago

0.62.0-f5f5273

2 years ago

0.62.0-439c0e2

2 years ago

0.62.0-b80bc6d

2 years ago

0.61.0-d577171

2 years ago

0.61.0-0a48b12

2 years ago

0.61.0-767343a

2 years ago

0.61.0-9d512b6

2 years ago

0.61.0-560d446

2 years ago

0.61.0-3a017c0

2 years ago

0.61.0-3dab0f7

2 years ago

0.61.0-4e6e197

2 years ago

0.61.0-4856e7e

2 years ago

0.61.0-c823b55

2 years ago

0.60.0-4568528

2 years ago

0.60.0-57d7d63

2 years ago

0.59.0-4ee9753

2 years ago

0.59.0-cab1f75

2 years ago

0.59.0-695a89f

2 years ago

0.59.0-d889922

2 years ago

0.59.0-5d274f7

2 years ago

0.59.0-f27bbc7

2 years ago

0.57.1-a51a249

2 years ago

0.57.1-9d8e4ca

2 years ago

0.57.1-e7c525d

2 years ago

0.54.0-6f0e123

3 years ago

0.55.0-492661d

2 years ago

0.57.1-b54b611

2 years ago

0.56.0-a0c662a

2 years ago

0.56.0-36800cb

2 years ago

0.56.0-dacff4c

2 years ago

0.56.0-f4b405b

2 years ago

0.54.0-bba4463

3 years ago

0.57.0-d136ffe

2 years ago

0.54.0-a0fa070

3 years ago

0.55.0-7a41260

3 years ago

0.54.0-e923d25

3 years ago

0.57.1-22e31a9

2 years ago

0.55.0-dc6231b

3 years ago

0.56.0-d59cf1b

2 years ago

0.59.0-c19c94c

2 years ago

0.57.0-744e060

2 years ago

0.58.0-bcc5819

2 years ago

0.54.0-23daa80

3 years ago

0.56.0-0547eab

2 years ago

0.54.0-17b5ef8

3 years ago

0.53.1-ea4f547

3 years ago

0.52.0-2e845bb

3 years ago

0.53.1-60ed719

3 years ago

0.53.1-542f363

3 years ago

0.53.0-cada60f

3 years ago

0.52.0-2e7b3da

3 years ago

0.53.0-9c4fd68

3 years ago

0.52.0-1a5d166

3 years ago

0.52.0-2d0aea5

3 years ago

0.52.0-1c9c6a7

3 years ago

0.51.0-6283e1a

3 years ago

0.51.0-8e3aa00

3 years ago

0.51.0-4ae0204

3 years ago

0.52.0-928ff9a

3 years ago

0.49.2-bc37a1c

3 years ago

0.49.2-8df6b07

3 years ago

0.49.2-3a2cffd

3 years ago

0.49.2-6e43e1d

3 years ago

0.49.2-d849bbb

3 years ago

0.49.2-5b30a53

3 years ago

0.49.2-83f08a7

3 years ago

0.49.2-242b5a5

3 years ago

0.49.2-9af1677

3 years ago

0.49.2-d10f737

3 years ago

0.49.2-06c350e

3 years ago

0.51.0-60e1e34

3 years ago

0.49.2-ab5079b

3 years ago

0.51.0-b92d7a9

3 years ago

0.51.0-08f1540

3 years ago

0.49.2-7e38c59

3 years ago

0.49.2-4052cc0

3 years ago

0.49.2-2c35f33

3 years ago

0.49.2-53da8ff

3 years ago

0.49.2-f8bfc73

3 years ago

0.49.0-262a8ac

3 years ago

0.49.0-31c62a2

3 years ago

0.49.0-16e9b61

3 years ago

0.49.0-6b587e0

3 years ago

0.49.0-aa86363

3 years ago

0.49.0-8e391e4

3 years ago

0.49.0-22100ad

3 years ago

0.49.0-8ccabe0

3 years ago

0.49.0-f55e00f

3 years ago

0.49.0-c5ab8b4

3 years ago

0.49.0-55e6a53

3 years ago

0.49.0-8e462cb

3 years ago

0.49.0-02f5dd8

3 years ago

0.49.0-3589a40

3 years ago

0.49.0-9700926

3 years ago

0.48.0-27a6bdf

3 years ago

0.48.0-0875ed2

3 years ago

0.48.0-b92472e

3 years ago

0.48.0-8c2404a

3 years ago

0.48.0-5975603

3 years ago

0.47.4-520f5b1

3 years ago

0.47.4-eddfd29

3 years ago

0.47.3-719c627

3 years ago

0.47.2-ce233d9

3 years ago

0.47.1-05a73ca

3 years ago

0.47.0-634a664

3 years ago

0.46.1-653ce00

3 years ago

0.46.1-5cd63d6

3 years ago

0.45.0-85f9c34

3 years ago

0.45.0-4f1e5c5

3 years ago

0.45.0-74a2cd7

3 years ago

0.45.0-bc8cbde

3 years ago

0.45.0-fded27e

3 years ago

0.45.0-245383d

3 years ago

0.44.0-dc1fa34

3 years ago

0.44.0-fb05e92

3 years ago

0.44.0-c21bb75

3 years ago

0.44.0-d7108f7

3 years ago

0.44.0-48c5e21

3 years ago

0.44.0-2ae13a9

3 years ago

0.44.0-f6dc4f7

3 years ago

0.44.0-954dc57

3 years ago

0.44.0-a267835

3 years ago

0.44.0-107b68a

3 years ago

0.44.0-59f8b28

3 years ago

0.44.0-ff6f07e

3 years ago

0.44.0-526d4d5

3 years ago

0.44.0-46c6aed

3 years ago

0.44.0-db1c2c8

3 years ago

0.44.0-ef4374c

3 years ago

0.44.0-d1c36e2

3 years ago

0.44.0-295f1bc

3 years ago

0.43.1-a908484

3 years ago

0.43.1-e6d0525

3 years ago

0.43.1-3c714b8

3 years ago

0.43.0-648603c

3 years ago

0.43.0-cfa7d7b

3 years ago

0.43.0-4f4165b

3 years ago

0.43.0-211d568

3 years ago

0.43.0-f9d7862

3 years ago

0.43.0-6177839

3 years ago

0.43.0-0bb510f

3 years ago

0.43.0-5a16523

3 years ago

0.43.0-870c22f

3 years ago

0.43.0-7675e56

3 years ago

0.43.0-eb316bf

3 years ago

0.43.0-6906bff

3 years ago

0.43.0-1496357

3 years ago

0.43.0-7567344

3 years ago