An Open Policy Agent Compile Response Parser
Open Policy Agent provides a compile API that allows you partially evaluate your policy.
This library can parse the compile JSON response and allow you to access the Rego AST (Abstract Syntax Tree) in the response body by Rego language structure.
Moreover, it further processes the AST to:
https://t83714.github.io/opa-compile-response-parser/
import OpaCompileResponseParser from "opa-compile-response-parser";
const parser = new OpaCompileResponseParser();
parser.parse(jsonResponse);
const result = parser.evaluate();
/**
returned evaluate result:
interface CompleteRuleResult {
fullName: string;
name: string;
value: RegoValue;
isCompleteEvaluated: boolean;
residualRules?: RegoRule[];
}
*/
// --- Print residual rules as human readable string
console.log(parser.evaluateAsHumanReadableString());
Tested with Open Policy Agent version 0.37.2
Generated using TypeDoc