@highflame/policy 2.2.43 → 2.2.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -251,11 +251,13 @@ export function expressionToCedar(expr, optionalFields) {
251
251
  .join(' || ');
252
252
  }
253
253
  case 'not': {
254
- const inner = expressionToCedar(expr.child, optionalFields);
255
- // If inner is a simple leaf, no parens needed after !
256
- if (isLeaf(expr.child))
257
- return `!${inner}`;
258
- return `!(${inner})`;
254
+ // Always parenthesized. `!` binds tighter than every operator a
255
+ // leaf renders with, so dropping the parens re-associates the
256
+ // expression: `!context.score > 70` is `(!context.score) > 70`,
257
+ // which the Cedar validator rejects as "expected Bool but saw
258
+ // Long", and `!context has x` is `(!context) has x`. A leaf is not
259
+ // an atom.
260
+ return `!(${expressionToCedar(expr.child, optionalFields)})`;
259
261
  }
260
262
  case 'raw': {
261
263
  if (isValidRawCondition(expr.text)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highflame/policy",
3
- "version": "2.2.43",
3
+ "version": "2.2.44",
4
4
  "engines": {
5
5
  "node": ">=18"
6
6
  },