Fix bindings and add CI tests (#247)

Also update version numbers of binding Rust projects to match Regorus

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-05-22 11:15:42 -04:00
committed by GitHub
parent 495e91c75a
commit 9894f00829
35 changed files with 448 additions and 107 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "regorusjs"
version = "0.1.0"
version = "0.1.5"
edition = "2021"
repository = "https://github.com/microsoft/regorus/bindings/wasm"
description = "WASM bindings for Regorus - a fast, lightweight Rego interpreter written in Rust"
+1 -1
View File
@@ -50,7 +50,7 @@ impl Engine {
///
/// * `path`: A filename to be associated with the policy.
/// * `rego`: Rego policy.
pub fn add_policy(&mut self, path: String, rego: String) -> Result<(), JsValue> {
pub fn add_policy(&mut self, path: String, rego: String) -> Result<String, JsValue> {
self.engine.add_policy(path, rego).map_err(error_to_jsvalue)
}
+3 -2
View File
@@ -7,7 +7,7 @@ var regorus = require('./pkg/regorusjs')
var engine = new regorus.Engine();
// Add Rego policy.
engine.add_policy(
var pkg = engine.add_policy(
// Associate this file name with policy
'hello.rego',
@@ -18,6 +18,7 @@ engine.add_policy(
# Join messages
message = concat(", ", [input.message, data.message])
`)
console.log("Loaded policy " + pkg)
// Set policy data
engine.add_data_json(`
@@ -34,7 +35,7 @@ engine.set_input_json(`
`)
// Eval query
results = engine.eval_query('data.test.message')
var results = engine.eval_query('data.test.message')
// Display
console.log(results)