From 00c1ee4c4d1766fd749269edf99ace2ef644dcfb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Jul 2024 09:25:55 +0000 Subject: [PATCH] Version Packages --- .changeset/tough-cows-kiss.md | 25 ------------------------- packages/opa-react/CHANGELOG.md | 26 ++++++++++++++++++++++++++ packages/opa-react/package.json | 2 +- 3 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 .changeset/tough-cows-kiss.md diff --git a/.changeset/tough-cows-kiss.md b/.changeset/tough-cows-kiss.md deleted file mode 100644 index 793cc9ee..00000000 --- a/.changeset/tough-cows-kiss.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -"@styra/opa-react": minor ---- - -Add `fromResults` to support unwrapping policy evaluation results - -This allows us to unwrap results returned from OPA to turn them into a boolean. - -Previously, anything different from undefined and false was taken to mean "authorized". Now, we can work with policy evaluation results like - -```json -{ - "result": false, - "details": "..." -} -``` - -by providing a `fromResults` function like - -```ts -const fromResults = (r?: Result): boolean => - ((r as Record)["foobar"] as boolean) ?? false; -``` - -As with input and path, this can (optionally) be set with `` (property `defaultFromResults`), and with `` (property `fromResult`), or passed to `useAuthz()`. diff --git a/packages/opa-react/CHANGELOG.md b/packages/opa-react/CHANGELOG.md index fb7cb3bd..07638e00 100644 --- a/packages/opa-react/CHANGELOG.md +++ b/packages/opa-react/CHANGELOG.md @@ -1,5 +1,31 @@ # @styra/opa-react +## 0.3.0 + +### Minor Changes + +- d2b2abc: Add `fromResults` to support unwrapping policy evaluation results + + This allows us to unwrap results returned from OPA to turn them into a boolean. + + Previously, anything different from undefined and false was taken to mean "authorized". Now, we can work with policy evaluation results like + + ```json + { + "result": false, + "details": "..." + } + ``` + + by providing a `fromResults` function like + + ```ts + const fromResults = (r?: Result): boolean => + ((r as Record)["foobar"] as boolean) ?? false; + ``` + + As with input and path, this can (optionally) be set with `` (property `defaultFromResults`), and with `` (property `fromResult`), or passed to `useAuthz()`. + ## 0.2.1 ### Patch Changes diff --git a/packages/opa-react/package.json b/packages/opa-react/package.json index 8379f123..6c1511fc 100644 --- a/packages/opa-react/package.json +++ b/packages/opa-react/package.json @@ -1,6 +1,6 @@ { "name": "@styra/opa-react", - "version": "0.2.1", + "version": "0.3.0", "repository": { "type": "git", "url": "https://github.com/StyraInc/opa-typescript.git",