Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ http = []
glob = ["dep:globset"]
graph = []
jsonschema = ["dep:jsonschema"]
jsonpatch = []
Comment thread
vitaliytv marked this conversation as resolved.
mimalloc = ["dep:mimalloc"]
net = ["dep:ipnet"]
no_std = ["lazy_static/spin_no_std"]
Expand All @@ -63,6 +64,7 @@ full-opa = [
"hex",
"http",
"jsonschema",
"jsonpatch",
"net",
"opa-runtime",
"regex",
Expand All @@ -86,6 +88,7 @@ opa-no-std = [
"coverage",
"graph",
"hex",
"jsonpatch",
"no_std",
"opa-runtime",
"regex",
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ The following test suites don't pass fully due to missing builtins:
- `globsmatch`
- `graphql`
- `invalidkeyerror`
- `jsonpatch`
- `jwtbuiltins`
- `jwtdecodeverify`
- `jwtencodesign`
Expand Down
1 change: 1 addition & 0 deletions bindings/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ default = [
"regorus/hex",
"regorus/http",
"regorus/jsonschema",
"regorus/jsonpatch",
"regorus/net",
"regorus/opa-runtime",
"regorus/regex",
Expand Down
18 changes: 18 additions & 0 deletions bindings/wasm/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ console.log(report);
report = engine.getCoverageReportPretty();
console.log(report);

// json.patch is available through the WASM default feature set.
{
const patchEngine = new regorus.Engine();
patchEngine.addPolicy('json-patch.rego', `
package wasm_patch
import rego.v1

result := json.patch(
{"a": [1, 2]},
[{"op": "replace", "path": "/a/1", "value": 9}],
)
`);
const patched = JSON.parse(patchEngine.evalRule('data.wasm_patch.result'));
if (JSON.stringify(patched) !== JSON.stringify({a: [1, 9]})) {
throw new Error(`Unexpected json.patch WASM result: ${JSON.stringify(patched)}`);
}
}

// RVM regular example
{
const policy = `
Expand Down
1 change: 1 addition & 0 deletions docs/builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ In future, each builtin will be associated with a feature (many builtins could b
|----------------------------------------------------------------------------------------------------------------------|--------------|
| [json.filter](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonfilter) | _ |
| [json.match_schema](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonmatch_schema) | `jsonschema` |
| [json.patch](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonpatch) | `jsonpatch` |
| [json.remove](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonremove) | _ |
| [json.verify_schema](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-jsonverify_schema) | `jsonschema` |
| [object.filter](https://www.openpolicyagent.org/docs/latest/policy-reference/#builtin-object-objectfilter) | _ |
Expand Down
3 changes: 3 additions & 0 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ pub struct RuleAssign {
pub struct RuleBody {
pub span: Span,
pub assign: Option<RuleAssign>,
/// True when this body was introduced by an `else` clause. Unlike
/// independent legacy query blocks, else bodies are mutually exclusive.
pub is_else: bool,
pub query: Ref<Query>,
}

Expand Down
Loading
Loading