Skip to content

Commit

Permalink
feat: Add pl_to_prql to JS bindings (#4332)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquayj authored Mar 14, 2024
1 parent f31eb03 commit f8acaf1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions prqlc/bindings/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function compile(prql_query: string, options?: CompileOptions): string;

function prql_to_pl(prql_query: string): string;

function pl_to_prql(pl_json: string): string;

function pl_to_rq(pl_json: string): string;

function rq_to_sql(rq_json: string): string;
Expand Down
9 changes: 9 additions & 0 deletions prqlc/bindings/js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ pub fn prql_to_pl(prql_query: &str) -> Option<String> {
)
}

#[wasm_bindgen]
pub fn pl_to_prql(pl_json: &str) -> Option<String> {
return_or_throw(
Ok(pl_json)
.and_then(prqlc::json::to_pl)
.and_then(|x| prqlc::pl_to_prql(&x)),
)
}

#[wasm_bindgen]
pub fn pl_to_rq(pl_json: &str) -> Option<String> {
return_or_throw(
Expand Down

0 comments on commit f8acaf1

Please sign in to comment.