openfga_dsl_parser/lib.rs
1//! # OpenFGA DSL Parser
2//!
3//! The OpenFGA DSL Parser provides utilities for parsing DSL file string inputs into an AST representation, as well as transforming them into a JSON representation.
4//!
5//! This library is meant to be a utility for services using [OpenFGA](https://openfga.dev/) for their authorization solution, but need a way to translate from their DSL to the JSON format the HTTP API expects. A [Typescript library](https://github.com/openfga/syntax-transformer) is available that does something similar, however this aims to target Rust, as well as be a base for other potential languages to bind to.
6//!
7//! # Usage
8//!
9//! ```
10//! # fn parse() -> openfga_dsl_parser::ParseResult<()> {
11//! use openfga_dsl_parser::{json, Parser};
12//!
13//! let input = "type group
14//! relations
15//! define member as self
16//! type resource
17//! relations
18//! define writer as self
19//! define reader as self but not writer";
20//!
21//! let mut parser = Parser::new(input);
22//! let doc = parser.parse_document()?;
23//!
24//! let json = json::JsonTransformer::new(&doc).serialize();
25//! # Ok(())
26//! # }
27//! ```
28
29pub mod ast;
30pub mod json;
31pub mod lexer;
32mod parser;
33
34pub use parser::*;